merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 16 Nov 2009 09:37:06 +0100
branchstable
changeset 3853 e8af6f586882
parent 3852 03121ca1f85e (current diff)
parent 3851 3a18a0a24411 (diff)
child 3854 8633cd05b6b5
merge
--- a/utils.py	Mon Nov 16 09:36:25 2009 +0100
+++ b/utils.py	Mon Nov 16 09:37:06 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