aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-06 19:50:31 +0200
committerMattias Andrée <maandree@kth.se>2016-07-06 19:50:35 +0200
commit9938dd7feeaf9fac98c89d14cae1ba703512c204 (patch)
tree42727656fd28c87b874c990e8f4551d7150d1a8b
parentThe rest of the program (diff)
downloadblue-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>
-rwxr-xr-xblue.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/blue.py b/blue.py
index 967b3a7..8eb4d87 100755
--- a/blue.py
+++ b/blue.py
@@ -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