diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 5fe64f3..91846ce 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -155,7 +155,14 @@ def create_event(component): event = Event() event.start = normalize(component.get('dtstart').dt) - event.end = normalize(component.get('dtend').dt) + + if component.get('dtend'): + event.end = normalize(component.get('dtend').dt) + elif component.get('duration'): + event.end = event.start + component.get('duration').dt + else: + raise ValueError("Event has neither end, nor duration property.") + event.summary = str(component.get('summary')) event.description = str(component.get('description')) event.all_day = type(component.get('dtstart').dt) is date @@ -345,6 +352,12 @@ def create_recurring_events(start, end, component): def extract_exdates(component): + """ + Compile a list of all exception dates stored with a component. + + :param component: icalendar iCal component + :return: exception dates + """ dates = [] exd_prop = component.get('exdate')