Parcourir la source

Fix end of month computation

Baptiste Jonglez il y a 10 ans
Parent
commit
2c44941018
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      coin/utils.py

+ 5 - 1
coin/utils.py

@@ -103,7 +103,11 @@ def start_of_month():
 
 
 def end_of_month():
-    return date(date.today().year, date.today().month + 1, 1) - timedelta(days=1)
+    today = date.today()
+    if today.month == 12:
+        return date(today.year + 1, 1, 1) - timedelta(days=1)
+    else:
+        return date(today.year, today.month + 1, 1) - timedelta(days=1)
 
 if __name__ == '__main__':
     print(ldap_hash('coin'))