From 74e659c33077839657bd702a9eb1ddd678ebc5c4 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lemburg Date: Fri, 13 Sep 2024 18:10:35 +0200 Subject: [PATCH] Deal with cases where DTEND is not given in the event dict (#2024) Fixes #2021. Co-authored-by: Jacob Coffee --- events/importer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/events/importer.py b/events/importer.py index e47775060..fe04d35f5 100644 --- a/events/importer.py +++ b/events/importer.py @@ -22,7 +22,13 @@ def import_occurrence(self, event, event_data): # but won't add any timezone information. We will convert them to # aware datetime objects manually. dt_start = extract_date_or_datetime(event_data['DTSTART'].dt) - dt_end = extract_date_or_datetime(event_data['DTEND'].dt) + if 'DTEND' in event_data: + # DTEND is not always set on events, in particular it seems that + # events which have the same start and end time, don't provide + # DTEND. See #2021. + dt_end = extract_date_or_datetime(event_data['DTEND'].dt) + else: + dt_end = dt_start # Let's mark those occurrences as 'all-day'. all_day = (