From c67e1bfb8b109d1bb837d950cd12791fbef12c5f Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 8 Jan 2023 13:46:11 +0100 Subject: [PATCH] ical: Handle event exceptions --- modules/ical.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/ical.py b/modules/ical.py index 1c4cbd7..7cbb859 100644 --- a/modules/ical.py +++ b/modules/ical.py @@ -1,3 +1,4 @@ +from collections.abc import Iterable from datetime import date, datetime, timedelta, timezone from functools import reduce import hashlib @@ -85,6 +86,18 @@ class IcalModule: start = next_weekday(todayd, weekday) 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["DTEND"] = vDDDTypes(end)