Hotfix - CalDAV/Wraps timezone addition in try catch (#8453)
* Wraps timezone addition in try catch * Suggestion accepted Co-authored-by: Alex van Andel <me@alexvanandel.com> --------- Co-authored-by: Alex van Andel <me@alexvanandel.com>pull/8457/head
parent
dd8968d0e7
commit
2eed750ef6
|
@ -323,9 +323,11 @@ 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) {
|
||||
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");
|
||||
|
@ -337,6 +339,10 @@ export default abstract class BaseCalendarService implements Calendar {
|
|||
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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue