Skip to content

Commit

Permalink
Merge pull request #26 from dlichtistw/Fix-EXDATE
Browse files Browse the repository at this point in the history
Fix exdate
  • Loading branch information
irgangla authored Sep 17, 2018
2 parents 74d6fd3 + 9803b50 commit 98ed17d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime, timedelta, date

from icalendar import Calendar
from icalendar.prop import vDDDLists
from pytz import utc


Expand Down Expand Up @@ -326,8 +327,27 @@ def create_recurring_events(start, end, component):
unfolded.append(current)
else:
break

return in_range(unfolded, start, end)

reduced_range = in_range(unfolded, start, end)

exceptions = extract_exdates(component)
reduced_exceptions = [ev for ev in reduced_range if ev.start not in exceptions]

return reduced_exceptions


def extract_exdates(component):
dates = []

exd_prop = component.get('exdate')
if exd_prop:
if isinstance(exd_prop, list):
for exd_list in exd_prop:
dates.extend(exd.dt for exd in exd_list.dts)
elif isinstance(exd_prop, vDDDLists):
dates.extend(exd.dt for exd in exd_prop.dts)

return dates


def generate_day_deltas_by_weekday(by_day):
Expand Down

0 comments on commit 98ed17d

Please sign in to comment.