fix(in-progress): maintain original timezone and not convert time to local timezone
This commit is contained in:
parent
441f4d2fb3
commit
3437d9bfa9
|
@ -34,6 +34,12 @@ export function createCalendarComponent(name) {
|
||||||
calendarComponent.updatePropertyWithValue('name', name);
|
calendarComponent.updatePropertyWithValue('name', name);
|
||||||
return calendarComponent;
|
return calendarComponent;
|
||||||
}
|
}
|
||||||
|
// Add timezone information
|
||||||
|
export function addTimezoneComponent(calendarComponent, timezoneId) {
|
||||||
|
const timezoneComponent = new ICAL.Component('vtimezone');
|
||||||
|
timezoneComponent.updatePropertyWithValue('tzid', timezoneId);
|
||||||
|
calendarComponent.addSubcomponent(timezoneComponent);
|
||||||
|
}
|
||||||
|
|
||||||
// Add events to the calendar component
|
// Add events to the calendar component
|
||||||
export function addEventsToCalendar(calendarComponent, results) {
|
export function addEventsToCalendar(calendarComponent, results) {
|
||||||
|
@ -45,13 +51,25 @@ export function addEventsToCalendar(calendarComponent, results) {
|
||||||
const vevent = new ICAL.Event(event);
|
const vevent = new ICAL.Event(event);
|
||||||
const newEvent = new ICAL.Component('vevent');
|
const newEvent = new ICAL.Component('vevent');
|
||||||
|
|
||||||
const startDate = vevent.startDate && ICAL.Time.fromJSDate(vevent.startDate.toJSDate());
|
// Define start and end times using original timezone info
|
||||||
const endDate = vevent.endDate && ICAL.Time.fromJSDate(vevent.endDate.toJSDate());
|
const startDate = vevent.startDate; // Keep the original startDate with timezone
|
||||||
|
const endDate = vevent.endDate; // Keep the original endDate with timezone
|
||||||
|
|
||||||
|
// Specify time zone ID for DTSTART and DTEND
|
||||||
|
const startProp = new ICAL.Property('dtstart');
|
||||||
|
startProp.setValue(startDate); // Use the original startDate directly
|
||||||
|
startProp.setParameter('tzid', startDate.zone.tzid); // Set the timezone ID
|
||||||
|
|
||||||
|
const endProp = new ICAL.Property('dtend');
|
||||||
|
endProp.setValue(endDate); // Use the original endDate directly
|
||||||
|
endProp.setParameter('tzid', endDate.zone.tzid); // Set the timezone ID
|
||||||
|
|
||||||
|
// Set properties for newEvent
|
||||||
|
newEvent.addProperty(startProp);
|
||||||
|
newEvent.addProperty(endProp);
|
||||||
newEvent.updatePropertyWithValue('uid', vevent.uid);
|
newEvent.updatePropertyWithValue('uid', vevent.uid);
|
||||||
newEvent.updatePropertyWithValue('summary', `${result.prefix} ${vevent.summary}`);
|
newEvent.updatePropertyWithValue('summary', `${result.prefix} ${vevent.summary}`);
|
||||||
newEvent.updatePropertyWithValue('dtstart', startDate);
|
|
||||||
newEvent.updatePropertyWithValue('dtend', endDate);
|
|
||||||
|
|
||||||
calendarComponent.addSubcomponent(newEvent);
|
calendarComponent.addSubcomponent(newEvent);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue