Skip to content

Commit

Permalink
Properly handle missing current_range
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSoft committed Jul 3, 2024
1 parent 7d1c9d0 commit ace8013
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hamster/widgets/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def update_today(self, today):
if today == self.today:
return False # unchanged

if self.current_range == "day":
if self.current_range == "day" or self.start_date == self.end_date:
old_start = old_end = self.today
new_start = new_end = today
elif self.current_range == "week":
Expand All @@ -177,9 +177,12 @@ def update_today(self, today):
old_start, old_end = stuff.month(self.today)
new_start, new_end = stuff.month(today)
else:
# manual range not touched, just bump today
self.today = today
return False # today changed under the hood but range not updated
old_start, old_end = self.start_date, self.end_date
if self.today < old_start or self.today > old_end:
self.today = today
return False
new_start = old_start + (today - self.today)
new_end = old_end + (today - self.today)

# now we can already set it
self.today = today
Expand Down

0 comments on commit ace8013

Please sign in to comment.