diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-06 19:50:31 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-06 19:50:35 +0200 |
commit | 9938dd7feeaf9fac98c89d14cae1ba703512c204 (patch) | |
tree | 42727656fd28c87b874c990e8f4551d7150d1a8b /blue.py | |
parent | The rest of the program (diff) | |
download | blue-9938dd7feeaf9fac98c89d14cae1ba703512c204.tar.gz blue-9938dd7feeaf9fac98c89d14cae1ba703512c204.tar.bz2 blue-9938dd7feeaf9fac98c89d14cae1ba703512c204.tar.xz |
Fix automatic stop date, was one day too late
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rwxr-xr-x | blue.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -208,9 +208,18 @@ if stop_date is not None: else: tm = time.localtime() if tm.tm_mon < 12: - stop_date = (tm.tm_year, tm.tm_mon + 1, tm.tm_mday) + y, m, d = tm.tm_year, tm.tm_mon + 1, tm.tm_mday - 1 else: - stop_date = (tm.tm_year + 1, 1, tm.tm_mday) + y, m, d = tm.tm_year + 1, 1, tm.tm_mday - 1 + if d < 1: + m -= 1 + if m < 1: + m = 12 + y -= 1 + days = 29 if y % 400 == 0 or (y % 4 == 0 and not y % 100 == 0) else 28 + days = [31, days, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31] + d = days[m - 1] + stop_date = (y, m, d) ## Get stop time |