Skip to content

Commit

Permalink
Make sure date only events have dates as a result
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann committed Feb 13, 2025
1 parent 66ede69 commit 2527101
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion recurring_ical_events/adapters/journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def raw_end(self) -> Time:
## VJOURNAL cannot have a DTEND. We should consider a VJOURNAL to
## describe one day if DTSTART is a date, and we can probably
## consider it to have zero duration if a timestamp is given.
return self.start
return self.raw_start


__all__ = ["JournalAdapter"]
5 changes: 0 additions & 5 deletions recurring_ical_events/test/test_time_zones_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def test_include_events_if_the_time_zone_differs(
start = tzinfo.localize(datetime.datetime(*date))
stop = start + datetime.timedelta(hours=hours)
events = calendars[calendar_name].between(start, stop)
if events:
start = events[0]["DTSTART"].dt
if isinstance(start, datetime.datetime):
offset = start - start.replace(tzinfo=tzinfo)
print(f"time zone offset {offset} between {start.tzinfo} and {tzinfo}")
assert (
len(events) == number_of_events
), f"in calendar {calendar_name} and {date} in {timezone}"
11 changes: 8 additions & 3 deletions recurring_ical_events/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ def make_comparable(dates: Sequence[Time]) -> list[Time]:
Returns an list.
"""
tzinfo = None
all_dates = True
for date in dates:
tzinfo = getattr(date, "tzinfo", None)
if tzinfo is not None:
break
if not is_date(date):
all_dates = False
if has_timezone(date):
tzinfo = date.tzinfo
break
if all_dates:
return dates
return [convert_to_datetime(date, tzinfo) for date in dates]


Expand Down

0 comments on commit 2527101

Please sign in to comment.