Replace all dates if any has the wrong type

This commit is contained in:
Unrud 2021-12-20 23:47:39 +01:00
parent fb3de73d1c
commit eac460d4d9

View File

@ -154,18 +154,15 @@ def check_and_sanitize_items(
ref_value_param = component.dtstart.params.get("VALUE") ref_value_param = component.dtstart.params.get("VALUE")
for dates in chain(component.contents.get("exdate", []), for dates in chain(component.contents.get("exdate", []),
component.contents.get("rdate", [])): component.contents.get("rdate", [])):
replace_value_param = False if all(type(d) == type(ref_date) for d in dates.value):
continue
for i, date in enumerate(dates.value): for i, date in enumerate(dates.value):
if type(date) != type(ref_date): dates.value[i] = ref_date.replace(
replace_value_param = True date.year, date.month, date.day)
dates.value[i] = ref_date.replace( with contextlib.suppress(KeyError):
date.year, date.month, date.day) del dates.params["VALUE"]
if replace_value_param: if ref_value_param is not None:
if ref_value_param is None: dates.params["VALUE"] = ref_value_param
with contextlib.suppress(KeyError):
del dates.params["VALUE"]
else:
dates.params["VALUE"] = ref_value_param
# vobject interprets recurrence rules on demand # vobject interprets recurrence rules on demand
try: try:
component.rruleset component.rruleset