Added getDaysInYear proc
This commit is contained in:
parent
8e24a11a31
commit
71743b5af3
1 changed files with 6 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nim's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2013 Andreas Rumpf
|
# (c) Copyright 2015 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
@ -240,7 +240,7 @@ proc isLeapYear*(year: int): bool =
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc getDaysInMonth*(month: Month, year: int): int =
|
proc getDaysInMonth*(month: Month, year: int): int =
|
||||||
## gets the amount of days in a ``month`` of a ``year``
|
## Get the number of days in a ``month`` of a ``year``
|
||||||
|
|
||||||
# http://www.dispersiondesign.com/articles/time/number_of_days_in_a_month
|
# http://www.dispersiondesign.com/articles/time/number_of_days_in_a_month
|
||||||
case month
|
case month
|
||||||
|
|
@ -248,6 +248,10 @@ proc getDaysInMonth*(month: Month, year: int): int =
|
||||||
of mApr, mJun, mSep, mNov: result = 30
|
of mApr, mJun, mSep, mNov: result = 30
|
||||||
else: result = 31
|
else: result = 31
|
||||||
|
|
||||||
|
proc getDaysInYear*(year: int): int =
|
||||||
|
## Get the number of days in a ``year``
|
||||||
|
result = 365 + (if isLeapYear(year): 1 else: 0)
|
||||||
|
|
||||||
proc toSeconds(a: TimeInfo, interval: TimeInterval): float =
|
proc toSeconds(a: TimeInfo, interval: TimeInterval): float =
|
||||||
## Calculates how many seconds the interval is worth by adding up
|
## Calculates how many seconds the interval is worth by adding up
|
||||||
## all the fields
|
## all the fields
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue