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,20 +323,26 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
const tzid: string | undefined = vevent?.getFirstPropertyValue("tzid") || isUTC ? "UTC" : timezone;
|
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
|
// 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) {
|
if (!vcalendar.getFirstSubcomponent("vtimezone") && tzid) {
|
||||||
const timezoneComp = new ICAL.Component("vtimezone");
|
try {
|
||||||
timezoneComp.addPropertyWithValue("tzid", tzid);
|
const timezoneComp = new ICAL.Component("vtimezone");
|
||||||
const standard = new ICAL.Component("standard");
|
timezoneComp.addPropertyWithValue("tzid", tzid);
|
||||||
// get timezone offset
|
const standard = new ICAL.Component("standard");
|
||||||
const tzoffsetfrom = dayjs(event.startDate.toJSDate()).tz(tzid).format("Z");
|
|
||||||
const tzoffsetto = dayjs(event.endDate.toJSDate()).tz(tzid).format("Z");
|
|
||||||
|
|
||||||
// set timezone offset
|
// get timezone offset
|
||||||
standard.addPropertyWithValue("tzoffsetfrom", tzoffsetfrom);
|
const tzoffsetfrom = dayjs(event.startDate.toJSDate()).tz(tzid).format("Z");
|
||||||
standard.addPropertyWithValue("tzoffsetto", tzoffsetto);
|
const tzoffsetto = dayjs(event.endDate.toJSDate()).tz(tzid).format("Z");
|
||||||
// provide a standard dtstart
|
|
||||||
standard.addPropertyWithValue("dtstart", "1601-01-01T00:00:00");
|
// set timezone offset
|
||||||
timezoneComp.addSubcomponent(standard);
|
standard.addPropertyWithValue("tzoffsetfrom", tzoffsetfrom);
|
||||||
vcalendar.addSubcomponent(timezoneComp);
|
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");
|
const vtimezone = vcalendar.getFirstSubcomponent("vtimezone");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue