Skip to content

Commit

Permalink
Merge pull request jazzband#27 from dlichtistw/development
Browse files Browse the repository at this point in the history
Add support for duration
  • Loading branch information
Thomas Irgang authored Sep 18, 2018
2 parents 1dd978b + 40fe0e5 commit 8497d5d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 8497d5d

Please sign in to comment.