Skip to content

Commit

Permalink
Merge pull request jazzband#88 from tresni/master
Browse files Browse the repository at this point in the history
Fix reversion of RRULE UNTIL behavior
  • Loading branch information
eigenmannmartin authored Nov 7, 2021
2 parents 9fcda2f + 16573fc commit a4919ad
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
9 changes: 3 additions & 6 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,9 @@ def parse_rrule(component, tz=UTC):
rdtstart = normalize(rdtstart, tz=tz)

# Remove/add timezone to rrule until dates depending on component
if type(rdtstart) is date:
for index, rru in enumerate(rrules):
if "UNTIL" in rru:
rrules[index]["UNTIL"] = adjust_timezone(
component, rru["UNTIL"], tz
)
for index, rru in enumerate(rrules):
if "UNTIL" in rru:
rrules[index]["UNTIL"] = adjust_timezone(component, rru["UNTIL"], tz)

# Parse the rrules, might return a rruleset instance, instead of rrule
rule = rrulestr(
Expand Down
43 changes: 43 additions & 0 deletions test/test_data/rrule_until_only_date.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:NotYourCalendar
X-WR-TIMEZONE:America/Boise
BEGIN:VTIMEZONE
TZID:America/Boise
X-LIC-LOCATION:America/Boise
BEGIN:DAYLIGHT
TZOFFSETFROM:-0700
TZOFFSETTO:-0600
TZNAME:MDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0600
TZOFFSETTO:-0700
TZNAME:MST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=America/Boise:20210929T130000
DTEND;TZID=America/Boise:20210929T135000
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20211020;BYDAY=MO,TH,WE
EXDATE;TZID=America/Boise:20211013T130000
DTSTAMP:20211029T011330Z
UID:[email protected]
CREATED:20210811T153934Z
DESCRIPTION:
LAST-MODIFIED:20210927T184338Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:LUNCH
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
END:VEVENT
END:VCALENDAR
15 changes: 15 additions & 0 deletions test/test_icalevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ def test_events_rrule_until_all_day_google(self):
self.assertEqual(ev_2.all_day, True, "All day event")
self.assertEqual(ev_2.summary, "Busy")

def test_events_rrule_until_only_date(self):
ical = "test/test_data/rrule_until_only_date.ics"
start = date(2021, 9, 29)
end = date(2021, 10, 19)
evs = icalevents.events(file=ical, start=start, end=end)
self.assertEqual(len(evs), 8)
self.assertEqual(
evs[0].start,
datetime(2021, 9, 29, 13, 0, 0, 0, tzinfo=gettz("America/Boise")),
)
self.assertEqual(
evs[-1].start,
datetime(2021, 10, 18, 13, 0, 0, 0, tzinfo=gettz("America/Boise")),
)

def test_events_rrule_until(self):
ical = "test/test_data/rrule_until.ics"
start = date(2019, 4, 2)
Expand Down

0 comments on commit a4919ad

Please sign in to comment.