kopia lustrzana https://github.com/jazzband/icalevents
Merge pull request #139 from jazzband/fix/show-active-events
fix: expand all events that are active in the defined windowpull/140/head
commit
8a689348dd
|
@ -404,7 +404,12 @@ def parse_events(
|
|||
|
||||
if e.recurring:
|
||||
rule = parse_rrule(component)
|
||||
for dt in rule.between(f, t, inc=True):
|
||||
# We can not use rule.between because the event has to fit in between https://github.com/jazzband/icalevents/issues/101
|
||||
for dt in [
|
||||
dt
|
||||
for dt in list(rule.between(f - (end - start), t + (end - start)))
|
||||
if dt >= f and dt <= t
|
||||
]:
|
||||
# Recompute the start time in the current timezone *on* the
|
||||
# date of *this* occurrence. This handles the case where the
|
||||
# recurrence has crossed over the daylight savings time boundary.
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
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
|
|
@ -5,6 +5,7 @@ from time import sleep
|
|||
from dateutil.relativedelta import relativedelta
|
||||
from dateutil.tz import UTC, gettz
|
||||
from re import search
|
||||
import textwrap
|
||||
import pytz
|
||||
|
||||
|
||||
|
@ -932,3 +933,15 @@ class ICalEventsTests(unittest.TestCase):
|
|||
"fourth event on 1. jan - 18. and 25. dec are excluded",
|
||||
)
|
||||
self.assertEqual(events[4].start, date(2024, 1, 8), "fifth event on 8. jan")
|
||||
|
||||
def test_regression_recurring_events_with_timezones(self):
|
||||
# we need to test if all active events are returned, even if they do not fit fully in the defined window
|
||||
tz = gettz("Europe/Berlin")
|
||||
ical = "test/test_data/recurring_small_window.ics"
|
||||
start = datetime(2022, 1, 11, 0, 0, 1, tzinfo=tz)
|
||||
end = datetime(2022, 1, 11, 8, 0, 1, tzinfo=tz)
|
||||
|
||||
events = icalevents.events(file=ical, start=start, end=end, strict=True)
|
||||
|
||||
self.assertEqual(len(events), 1)
|
||||
self.assertEqual(events[0].end.hour, 8)
|
||||
|
|
Ładowanie…
Reference in New Issue