Show in-progress multi-day events on the calendar.
CI / test (pull_request) Successful in 5s
Unit Tests / test (pull_request) Successful in 5s

Closes #32. Keep an event upcoming until its end date (and end time, when set) has passed, and render the Past tab from past events.
This commit is contained in:
westfarn committed 2026-10-06 13:06:01 -05:00
1 parent 531d97f3fc
commit 0048bf7cc2
3 files changed
+81 -15

No files matched your search

+21 -6
View File
@@ -77,17 +77,32 @@ class CalendarEvent(TimeInfoBase):
def has_date(self):
return not self.start_date is None
def _has_ended(self, now=None):
"""True once the event is over. In-progress multi-day events stay open
through end_date, and through end_time on that date when one is set.
"""
if not self.has_date():
return None
if now is None:
now = datetime.datetime.now()
end_date = self.end_date or self.start_date
if self.end_time:
return now >= datetime.datetime.combine(end_date, self.end_time)
return now.date() > end_date
def past_event(self):
if self.has_date():
return self.start_date <= datetime.datetime.now().date()
else:
ended = self._has_ended()
if ended is None:
return False
return ended
def future_event(self):
if self.has_date():
return self.start_date > datetime.datetime.now().date()
else:
"""Upcoming or currently in progress."""
ended = self._has_ended()
if ended is None:
return False
return not ended
def no_date(self):
return not self.has_date()