From 9938dd7feeaf9fac98c89d14cae1ba703512c204 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 6 Jul 2016 19:50:31 +0200 Subject: Fix automatic stop date, was one day too late MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- blue.py | 13 +++++++++++-- 1 file 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 -- cgit v1.2.3-70-g09d2