diff options
author | Ben Sima <ben@bsima.me> | 2018-11-28 14:18:28 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2018-11-28 14:18:28 -0800 |
commit | 21941174774c9a4397db27a0443e25df9aa44738 (patch) | |
tree | f7fd76362629b722d3995a5c636a2f56b81b53b2 /progress.py | |
parent | fdca2d17474785a058df43f9d9d418c14fbd0a7a (diff) |
Handle leap years
Diffstat (limited to 'progress.py')
-rwxr-xr-x | progress.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/progress.py b/progress.py index 411f605..bb5c571 100755 --- a/progress.py +++ b/progress.py @@ -9,12 +9,14 @@ class Progress(object): def __init__(self): self.now = datetime.now() weekdays_left = timedelta(7 - self.now.isoweekday()) - month_max = max(list(Calendar().itermonthdays(self.now.year, self.now.month))) + cal = Calendar() + month_max = max(list(cal.itermonthdays(self.now.year, self.now.month))) + year_max = 366 if isleap(self.now.year) else 365 self.dura = { 'day': timedelta(hours=8), 'week': timedelta(days=7), 'month': timedelta(days=month_max), - 'year': timedelta(days=365), + 'year': timedelta(days=year_max), } self.end = { 'year': datetime(self.now.year+1, 1, 1), |