diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 40970d5..e0176c2 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -112,7 +112,7 @@ class Event: duration = self.end - self.start ne.end = (new_start + duration) - ne.all_day = (self.all_day and (new_start - self.start).seconds == 0) + ne.all_day = self.all_day ne.uid = uid return ne diff --git a/test/test_data/recurring.ics b/test/test_data/recurring.ics index 7c903fd..3e65d6d 100644 --- a/test/test_data/recurring.ics +++ b/test/test_data/recurring.ics @@ -6,7 +6,7 @@ BEGIN:VEVENT DTSTART;TZID=Europe/Berlin:20181003T100000 DTEND;TZID=Europe/Berlin:20181003T120000 DESCRIPTION:Event recurring on wednesday each week, except on 2018-10-29 -SUMARRY:Recurring Event +SUMMARY:Recurring Event RRULE:FREQ=WEEKLY;BYDAY=MO EXDATE;TZID=Europe/Berlin:20181029T100000 END:VEVENT @@ -14,9 +14,16 @@ BEGIN:VEVENT DTSTART;TZID=Europe/Berlin:20180601T100000 DTEND;TZID=Europe/Berlin:20180601T120000 DESCRIPTION:Event recurring on friday each week, except on 2018-06-08/22 -SUMARRY:Recurring Event +SUMMARY:Recurring Event RRULE:FREQ=WEEKLY;BYDAY=FR EXDATE;TZID=Europe/Berlin:20180608T100000 EXDATE;TZID=Europe/Berlin:20180622T100000 END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20181030 +DTEND;VALUE=DATE:20181031 +DESCRIPTION:All-day event recurring on tuesday each week +SUMMARY:Recurring All-day Event +RRULE:FREQ=WEEKLY;BYDAY=TU +END:VEVENT END:VCALENDAR diff --git a/test/test_icalevents.py b/test/test_icalevents.py index f9ee2e6..f67a4a3 100644 --- a/test/test_icalevents.py +++ b/test/test_icalevents.py @@ -81,6 +81,33 @@ class ICalEventsTests(unittest.TestCase): self.assertEqual(evs[1].start.day, 15, "check first exdate.") self.assertEqual(evs[2].start.day, 29, "check second exdate.") + def test_events_all_day_recurring(self): + ical = "test/test_data/recurring.ics" + start = date(2018, 10, 30) + end = date(2018, 10, 31) + + evs = icalevents.events(file=ical, start=start, end=end) + + event_set = icalevents.events(url=None, file=ical, start=start, end=end) + ev = event_set[0] + + self.assertEqual(len(event_set), 1) + self.assertEqual(ev.summary, "Recurring All-day Event") + self.assertEqual(ev.description, "All-day event recurring on tuesday each week") + self.assertTrue(ev.all_day, "Recurring All-day Event's first instance is an all-day event") + + start_2nd_instance = date(2018, 11, 6) + end_2nd_instance = date(2018, 11, 7) + + event_set2 = icalevents.events(url=None, file=ical, start=start_2nd_instance, end=end_2nd_instance) + ev_2 = event_set2[0] + + self.assertEqual(len(event_set2), 1) + self.assertEqual(ev_2.summary, "Recurring All-day Event") + self.assertEqual(ev_2.description, "All-day event recurring on tuesday each week") + self.assertTrue(ev_2.all_day, "Recurring All-day Event's second instance is an all-day event") + + def test_event_attributes(self): ical = "test/test_data/basic.ics" start = date(2017, 7, 12)