added days_in_year function stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Mon, 16 Nov 2009 08:58:35 +0100
branchstable
changeset 3851 3a18a0a24411
parent 3850 75023c2c34ee
child 3853 e8af6f586882
added days_in_year function
utils.py
--- a/utils.py	Sun Nov 15 13:58:33 2009 +0100
+++ b/utils.py	Mon Nov 16 08:58:35 2009 +0100
@@ -52,6 +52,13 @@
 def days_in_month(date_):
     return monthrange(date_.year, date_.month)[1]
 
+def days_in_year(date_):
+    feb = pydatetime.date(date_.year, 2, 1)
+    if days_in_month(feb) == 29:
+        return 366
+    else:
+        return 365
+
 def previous_month(date_, nbmonth=1):
     while nbmonth:
         date_ = first_day(date_) - ONEDAY