From cac347d197f6fdb75ff16268a9fffe778117481b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 29 Jul 2025 11:27:41 -0700 Subject: [PATCH 1/2] =?UTF-8?q?BUG:=20dates=20have=20been=20converted=20to?= =?UTF-8?q?=20UTC=20already,=20don=E2=80=99t=20inherit=20tz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yaml2ics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yaml2ics.py b/yaml2ics.py index 9ff17cf..fc3088e 100644 --- a/yaml2ics.py +++ b/yaml2ics.py @@ -123,11 +123,11 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event: if "except_on" in repeat: exdates = [datetime2utc(rdate) for rdate in repeat["except_on"]] - add_recurrence_property(event, "EXDATE", exdates, tz) + add_recurrence_property(event, "EXDATE", exdates) if "also_on" in repeat: rdates = [datetime2utc(rdate) for rdate in repeat["also_on"]] - add_recurrence_property(event, "RDATE", rdates, tz) + add_recurrence_property(event, "RDATE", rdates) event.dtstamp = utcnow() if tz and event.floating and not event.all_day: From b04ca6be8588ac8c4792e838a0d556f1a98e6a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 29 Jul 2025 11:42:44 -0700 Subject: [PATCH 2/2] BUG: keep the timezone info when converting to string --- yaml2ics.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yaml2ics.py b/yaml2ics.py index fc3088e..96359a8 100644 --- a/yaml2ics.py +++ b/yaml2ics.py @@ -26,11 +26,11 @@ } -def datetime2utc(date): +def datetime_to_str(date): if isinstance(date, datetime.datetime): - return datetime.datetime.strftime(date, "%Y%m%dT%H%M%S") + return datetime.datetime.strftime(date, "%Y%m%dT%H%M%S%z") elif isinstance(date, datetime.date): - return datetime.datetime.strftime(date, "%Y%m%d") + return datetime.datetime.strftime(date, "%Y%m%d%z") def utcnow(): @@ -122,12 +122,12 @@ def event_from_yaml(event_yaml: dict, tz: datetime.tzinfo = None) -> ics.Event: ) if "except_on" in repeat: - exdates = [datetime2utc(rdate) for rdate in repeat["except_on"]] - add_recurrence_property(event, "EXDATE", exdates) + exdates = [datetime_to_str(rdate) for rdate in repeat["except_on"]] + add_recurrence_property(event, "EXDATE", exdates, tz) if "also_on" in repeat: - rdates = [datetime2utc(rdate) for rdate in repeat["also_on"]] - add_recurrence_property(event, "RDATE", rdates) + rdates = [datetime_to_str(rdate) for rdate in repeat["also_on"]] + add_recurrence_property(event, "RDATE", rdates, tz) event.dtstamp = utcnow() if tz and event.floating and not event.all_day: