forked from ryanmwangi/CalMerger
feat(calendar): extract and include X-WR-TIMEZONE if available
This commit is contained in:
parent
5e3e8eab5b
commit
d15d0be707
|
@ -38,6 +38,8 @@ export function createCalendarComponent(name) {
|
||||||
|
|
||||||
// Add events to the calendar component
|
// Add events to the calendar component
|
||||||
export function addEventsToCalendar(calendarComponent, results, overrideFlag = false) {
|
export function addEventsToCalendar(calendarComponent, results, overrideFlag = false) {
|
||||||
|
let defaultTimeZone = null; // To store the first found X-WR-TIMEZONE
|
||||||
|
|
||||||
results.forEach((result) => {
|
results.forEach((result) => {
|
||||||
try {
|
try {
|
||||||
const parsed = ICAL.parse(result.data);
|
const parsed = ICAL.parse(result.data);
|
||||||
|
@ -52,6 +54,18 @@ export function addEventsToCalendar(calendarComponent, results, overrideFlag = f
|
||||||
calendarComponent.updatePropertyWithValue('method', method.toUpperCase());
|
calendarComponent.updatePropertyWithValue('method', method.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Extract X-WR-TIMEZONE if available
|
||||||
|
const wrTimeZone = component.getFirstPropertyValue('x-wr-timezone');
|
||||||
|
if (wrTimeZone) {
|
||||||
|
console.log(`Extracted X-WR-TIMEZONE: ${wrTimeZone}`);
|
||||||
|
// Set it as the default if not already set
|
||||||
|
if (!defaultTimeZone) {
|
||||||
|
defaultTimeZone = wrTimeZone;
|
||||||
|
if (!calendarComponent.getFirstPropertyValue('x-wr-timezone')) {
|
||||||
|
calendarComponent.updatePropertyWithValue('x-wr-timezone', defaultTimeZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Extract and add VTIMEZONE components
|
// Extract and add VTIMEZONE components
|
||||||
const timezones = component.getAllSubcomponents('vtimezone');
|
const timezones = component.getAllSubcomponents('vtimezone');
|
||||||
|
|
Loading…
Reference in New Issue