From 318e8f6c8c7504891c0b10191d2719ea3d1a2f4b Mon Sep 17 00:00:00 2001 From: dlichtistw Date: Mon, 17 Sep 2018 18:54:05 +0200 Subject: [PATCH 1/2] Add docstring Add description to extract_exdates function. --- icalevents/icalparser.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 5fe64f3..4727282 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -345,6 +345,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') From 40fe0e56cdc67ab76ba9b1607036777bedaf345b Mon Sep 17 00:00:00 2001 From: dlichtistw Date: Mon, 17 Sep 2018 19:43:32 +0200 Subject: [PATCH 2/2] Add: Event duration support Set end = start + duration, if there is no end property. --- icalevents/icalparser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 4727282..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