respect the timezone from the ical event (#2361)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
buschco 2022-04-04 23:52:52 +02:00 committed by GitHub
parent ffff59dd00
commit 2d6cb1eb73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,10 +248,12 @@ 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";
return {
start: event.startDate.toJSDate().toISOString(),
end: event.endDate.toJSDate().toISOString(),
start: dayjs.tz(event.startDate.toJSDate(), tzid).toISOString(),
end: dayjs.tz(event.endDate.toJSDate(), tzid).toISOString(),
};
});