From e9ec799e3ec0ce420ebbf316f87f884772984207 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 19 Apr 2024 17:09:11 +0200 Subject: [PATCH] Support events in UTC Events in UTC need to have TAG rem2ics_utc. Thanks to Dianne for the proposal and discussion. --- README.rst | 10 ++++++++++ remind.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/README.rst b/README.rst index 9b46cfc..c7a2e4d 100644 --- a/README.rst +++ b/README.rst @@ -67,6 +67,16 @@ Format of the Remind MSG body The ``%"`` is omitted, if there is no description in the iCalendar. +Support events in UTC +--------------------- + +Remind always uses the local timezone. +Use something like this to export events in UTC: + +:: + + REM Tue AT [9:00 + $MinsFromUTC] TAG rem2ics_utc MSG Event + Known limitations ----------------- diff --git a/remind.py b/remind.py index 6256b4f..0527881 100644 --- a/remind.py +++ b/remind.py @@ -131,6 +131,11 @@ def _parse_remind(self, filename: str, lines: str = "") -> dict[str, dict[str, A dtstart: datetime | date = datetime.strptime(entry["eventstart"], "%Y-%m-%dT%H:%M").replace( tzinfo=self._localtz ) + if "rem2ics_utc" in entry["tags"]: + utcoffset = datetime( + self._startdate.year, self._startdate.month, self._startdate.day, tzinfo=self._localtz + ).utcoffset() + dtstart = (dtstart - utcoffset).replace(tzinfo=ZoneInfo("UTC")) # type: ignore else: dtstart = datetime.strptime(entry["date"], "%Y-%m-%d").date()