summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorapense <apense@users.noreply.github.com>2015-07-06 01:03:34 -0400
committerapense <apense@users.noreply.github.com>2015-07-06 01:03:34 -0400
commit71743b5af37a60daf160b0ea3687ce4353bef8f2 (patch)
tree56f07b7f12e8132bbd0d8b0782bdc2991286b9a8 /lib/pure
parent8e24a11a319ce2b2ce66efe9cab23f103e071a1a (diff)
downloadNim-71743b5af37a60daf160b0ea3687ce4353bef8f2.tar.gz
Added `getDaysInYear` proc
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/times.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 597488782..e4d3f7494 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim's Runtime Library
-#        (c) Copyright 2013 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -240,7 +240,7 @@ proc isLeapYear*(year: int): bool =
     return false
 
 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
   case month
@@ -248,6 +248,10 @@ proc getDaysInMonth*(month: Month, year: int): int =
   of mApr, mJun, mSep, mNov: result = 30
   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 =
   ## Calculates how many seconds the interval is worth by adding up
   ## all the fields