Skip to content

Scheduling infrastructure for absolutely everyone.

Hotfix - CalDAV/Wraps timezone addition in try catch (#8453)

Syed Ali Shahbaz2eed750ef64b
diff --git a/packages/lib/CalendarService.ts b/packages/lib/CalendarService.ts
index 410bb6f3222..d4c0f620492 100644
--- a/packages/lib/CalendarService.ts
+++ b/packages/lib/CalendarService.ts
@@ -323,20 +323,26 @@ export default abstract class BaseCalendarService implements Calendar {
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");
- timezoneComp.addPropertyWithValue("tzid", tzid);
- const standard = new ICAL.Component("standard");
- // get timezone offset
- const tzoffsetfrom = dayjs(event.startDate.toJSDate()).tz(tzid).format("Z");
- const tzoffsetto = dayjs(event.endDate.toJSDate()).tz(tzid).format("Z");
-
- // set timezone offset
- standard.addPropertyWithValue("tzoffsetfrom", tzoffsetfrom);
- standard.addPropertyWithValue("tzoffsetto", tzoffsetto);
- // provide a standard dtstart
- standard.addPropertyWithValue("dtstart", "1601-01-01T00:00:00");
- timezoneComp.addSubcomponent(standard);
- vcalendar.addSubcomponent(timezoneComp);
+ try {
+ const timezoneComp = new ICAL.Component("vtimezone");
+ timezoneComp.addPropertyWithValue("tzid", tzid);
+ const standard = new ICAL.Component("standard");
+
+ // get timezone offset
+ const tzoffsetfrom = dayjs(event.startDate.toJSDate()).tz(tzid).format("Z");
+ const tzoffsetto = dayjs(event.endDate.toJSDate()).tz(tzid).format("Z");
+
+ // set timezone offset
+ standard.addPropertyWithValue("tzoffsetfrom", tzoffsetfrom);
+ standard.addPropertyWithValue("tzoffsetto", tzoffsetto);
+ // provide a standard dtstart
+ standard.addPropertyWithValue("dtstart", "1601-01-01T00:00:00");
+ timezoneComp.addSubcomponent(standard);
+ vcalendar.addSubcomponent(timezoneComp);
+ } catch (e) {
+ // Adds try-catch to ensure the code proceeds when Apple Calendar provides non-standard TZIDs
+ console.log("error in adding vtimezone", e);
+ }
}
const vtimezone = vcalendar.getFirstSubcomponent("vtimezone");