Merge pull request #26 from dlichtistw/Fix-EXDATE

Fix exdate
pull/25/head^2
Thomas Irgang 2018-09-17 06:34:05 +02:00 zatwierdzone przez GitHub
commit 98ed17d084
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 21 dodań i 1 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ from random import randint
from datetime import datetime, timedelta, date
from icalendar import Calendar
from icalendar.prop import vDDDLists
from pytz import utc
@ -326,8 +327,27 @@ def create_recurring_events(start, end, component):
unfolded.append(current)
else:
break
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 in_range(unfolded, start, end)
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):