Skip to content

Commit

Permalink
Fix issue with DST starting/ending causing overlaps/gaps
Browse files Browse the repository at this point in the history
By looping through each event and using normalize, the tzinfo might change DST status. We can check for this change in DST status to adjust the end date either forward or backward, depending if DST stopped or started.
  • Loading branch information
zackman0010 committed Nov 19, 2024
1 parent 357b5c4 commit 9d48c88
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def get_events_from_ical_between(
end_date + datetime.timedelta(days=EXTRA_LOOKUP_DAYS),
)

for event in events:
if hasattr(event[ICAL_DATETIME_END].dt,'tzinfo'):
dt = event[ICAL_DATETIME_END].dt
tz = dt.tzinfo
normalized = tz.normalize(dt)
if normalized.tzinfo != tz:
diff = dt.dst() - normalized.dst()
event[ICAL_DATETIME_END].dt = normalized + diff

def filter_extra_days(event):
event_start, event_end = self.get_start_and_end_with_respect_to_event_type(event)
if event_start > event_end:
Expand Down

0 comments on commit 9d48c88

Please sign in to comment.