]> gitweb.pimeys.fr Git - today.git/commitdiff
[saints] Il faut penser au modulo quand on est en fin de mois
authorVincent Le Gallic <legallic@crans.org>
Sat, 4 May 2013 17:24:53 +0000 (19:24 +0200)
committerVincent Le Gallic <legallic@crans.org>
Sat, 4 May 2013 17:24:53 +0000 (19:24 +0200)
today.py

index 81cc8b8e6f7e43133c5aae90336ffbf7d8dbe6cd..80d05fb3caef6e0c5e675307c023c65e1b9d37e0 100755 (executable)
--- a/today.py
+++ b/today.py
@@ -181,7 +181,14 @@ def get_saints():
     now = get_now()
     saints = {}
     saints["today"] = _parse_saint(sourcesaints[now.month - 1][now.day - 1])
-    saints["tomorrow"] = _parse_saint(sourcesaints[now.month - 1][now.day])
+    nbdays = len(sourcesaints[now.month - 1])
+    if now.day == nbdays: # il faut regarder le mois suivant
+        if now.month == 12: # il faut regarder l'année suivante
+            saints["tomorrow"] = _parse_saint(sourcesaints[0][0])
+        else:
+            saints["tomorrow"] = _parse_saint(sourcesaints[now.month][0])
+    else:
+        saints["tomorrow"] = _parse_saint(sourcesaints[now.month - 1][now.day])
     firstnames = _get_firstnames()
     towish = {"today" : [], "tomorrow" : []}
     for day in ["today", "tomorrow"]: