Error handling recurring events with timezones
Following code snippet do not yield the expected result:
from datetime import datetime
from icalevents.icalevents import events
import textwrap
import zoneinfo
tz = zoneinfo.ZoneInfo("Europe/Berlin")
ics = textwrap.dedent(
"""\
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:STANDARD
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20211129T000000
DTEND;TZID=Europe/Berlin:20211129T080000
RRULE:FREQ=WEEKLY;UNTIL=20221230T230000Z;BYDAY=MO,TU,WE
END:VEVENT
END:VCALENDAR
"""
).encode()
events = events(
string_content=ics,
start=datetime(2022, 1, 11, 7, 0, 1, tzinfo=tz),
end=datetime(2022, 1, 11, 8, 0, 1, tzinfo=tz),
)
assert len(events) == 1
print(events[0])
I would expect the currently active recurring event instance. This holds for all start values of the last hour of the recurring event.
Git bisect yields efb7fbe3b4a762564c31ff9949daf04cff49c43b as the first bad commit introduced in #80
You're excluding the event by passing in a parse date range of 2022-01-11T07:00 - 2022-01-11T08:00, when the event is defined as repeating from 2021-11-29 - 2021-12-30.
Your code returns 0 events, which seems correct based on the calendar provided and the date range passed to events.
What date/time did you expect the single returned event to have?
You're excluding the event by passing in a parse date range of 2022-01-11T07:00 - 2022-01-11T08:00, when the event is defined as repeating from 2021-11-29 - 2021-12-30.
Repeating until 20221230T230000Z -> 2022-12-30. So I expect the event with DTSTART;TZID=Europe/Berlin:20220111T000000 | DTEND;TZID=Europe/Berlin:20220111T080000 to be returned.
@chrko you are right! I have located the problem, that rule.between will not expand the event if it does not fit in the between definition. I will try to find a better solution. :-)