Fix with ical convert to zone (#2377)

Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/2388/head^2
alannnc 2022-04-05 13:01:47 -06:00 committed by GitHub
parent f8b7e17fda
commit 9d512e70c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -248,12 +248,16 @@ export default abstract class BaseCalendarService implements Calendar {
const vcalendar = new ICAL.Component(jcalData);
const vevent = vcalendar.getFirstSubcomponent("vevent");
const event = new ICAL.Event(vevent);
const timezoneComp = vcalendar.getFirstSubcomponent("vtimezone");
const tzid: string = timezoneComp?.getFirstPropertyValue("tzid") ?? "UTC";
const vtimezone = vcalendar.getFirstSubcomponent("vtimezone");
if (vtimezone) {
const zone = new ICAL.Timezone(vtimezone);
event.startDate = event.startDate.convertToZone(zone);
event.endDate = event.endDate.convertToZone(zone);
}
return {
start: dayjs.tz(event.startDate.toJSDate(), tzid).toISOString(),
end: dayjs.tz(event.endDate.toJSDate(), tzid).toISOString(),
start: dayjs(event.startDate.toJSDate()).toISOString(),
end: dayjs(event.endDate.toJSDate()).toISOString(),
};
});