From: Vincent Le Gallic Date: Sat, 4 May 2013 17:24:53 +0000 (+0200) Subject: [saints] Il faut penser au modulo quand on est en fin de mois X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=7ad2e9146c3b7276edf5d36359bb1015a6cb156e;p=today.git [saints] Il faut penser au modulo quand on est en fin de mois --- diff --git a/today.py b/today.py index 81cc8b8..80d05fb 100755 --- 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"]: