ical: Handle event exceptions

This commit is contained in:
nemunaire 2023-01-08 13:46:11 +01:00
parent 671110d178
commit c67e1bfb8b

View File

@ -1,3 +1,4 @@
from collections.abc import Iterable
from datetime import date, datetime, timedelta, timezone from datetime import date, datetime, timedelta, timezone
from functools import reduce from functools import reduce
import hashlib import hashlib
@ -85,6 +86,18 @@ class IcalModule:
start = next_weekday(todayd, weekday) start = next_weekday(todayd, weekday)
end = start + diff end = start + diff
exclusions = []
if "EXDATE" in component:
exdates = component.decoded("EXDATE")
if isinstance(exdates, Iterable):
for exdate in exdates:
exclusions.append(exdate.dts[0].dt)
else:
exclusions.append(exdates.dts[0].dt)
while start in exclusions:
start += timedelta(days=7)
component["DTSTART"] = vDDDTypes(start) component["DTSTART"] = vDDDTypes(start)
component["DTEND"] = vDDDTypes(end) component["DTEND"] = vDDDTypes(end)