From 68ec49570ffbfd03de59be1999544156207dce4d Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Wed, 26 Jan 2022 20:38:32 +0200 Subject: [PATCH 1/2] Don't replace timezone of all day events - This fails as defined by ics-py (you would think that event.floating would handle this, but apparently not). - Also add a test for this --- tests/test_calendar.py | 3 +++ yaml2ics.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_calendar.py b/tests/test_calendar.py index 3240f5b..d720a91 100644 --- a/tests/test_calendar.py +++ b/tests/test_calendar.py @@ -45,6 +45,9 @@ def test_calendar_default_timezone(): - summary: February 1 begin: 2022-02-01 00:00:00 +02:00 duration: {hours: 1} + + - summary: Earth day (all day) + begin: 2022-04-22 ''' ))] ) diff --git a/yaml2ics.py b/yaml2ics.py index 54df116..3481594 100644 --- a/yaml2ics.py +++ b/yaml2ics.py @@ -75,7 +75,7 @@ def event_from_yaml(event_yaml: dict, tz: tzinfo=None) -> ics.Event: )) event.dtstamp = datetime.utcnow().replace(tzinfo=dateutil.tz.UTC) - if tz and event.floating: + if tz and event.floating and not event.all_day: event.replace_timezone(tz) return event From 09813526de010bc112dd1b54ef68f68c5488f838 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Wed, 26 Jan 2022 20:50:51 +0200 Subject: [PATCH 2/2] Fix test: #7 broke test by re-adding DTEND to recurring events - After #7, the length of recurring events is not made null - This means that all-day recurring events now have a DTEND property which is one day after the start day. This appears to be intentional: an all-day recurring event on day N has DTSTART=(N) and DTEND=(N+1). Furthermore, tests with Thunderbird and Google Calendar report that the new (post-#7) behavior is imported correctly. - However, #7 has broken the tests, undetected to me. This fixes the test by removing the check which is no longer needed. --- tests/test_events.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_events.py b/tests/test_events.py index 39efe57..7dfbc77 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -60,7 +60,8 @@ def test_rrule(): ) ) event_str = event.serialize() - assert 'DTEND' not in event_str + # DTEND exists and is the next day, calendar tools import this + # correctly as being a one-day event assert 'RRULE:FREQ=YEARLY;UNTIL=20300422T000000' in event_str