From d3e4d26fa50cb9265e18f8ef93f3f1d3ff2c9c66 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Date: Sat, 3 Dec 2022 01:16:38 +0530 Subject: [PATCH] fixes UTC consideration in CalDAV (#5827) * fixes UTC consideration * typecheck fix * code quality * comment location Co-authored-by: Alex van Andel --- packages/lib/CalendarService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/lib/CalendarService.ts b/packages/lib/CalendarService.ts index 7e51861bfa..38cf6c6d28 100644 --- a/packages/lib/CalendarService.ts +++ b/packages/lib/CalendarService.ts @@ -313,7 +313,9 @@ export default abstract class BaseCalendarService implements Calendar { const event = new ICAL.Event(vevent); const dtstart: { [key: string]: string } | undefined = vevent?.getFirstPropertyValue("dtstart"); const timezone = dtstart ? dtstart["timezone"] : undefined; - const tzid: string | undefined = vevent?.getFirstPropertyValue("tzid") || timezone; + // We check if the dtstart timezone is in UTC which is actually represented by Z instead, but not recognized as that in ICAL.js as UTC + const isUTC = timezone === "Z"; + const tzid: string | undefined = vevent?.getFirstPropertyValue("tzid") || isUTC ? "UTC" : timezone; // In case of icalendar, when only tzid is available without vtimezone, we need to add vtimezone explicitly to take care of timezone diff if (!vcalendar.getFirstSubcomponent("vtimezone") && tzid) { const timezoneComp = new ICAL.Component("vtimezone");