Bryan 2023-12-11 07:40:54 -06:00
commit 33ebf4c101
2 changed files with 8 additions and 4 deletions

View File

@ -32,12 +32,14 @@ function readFile(input) {
const jCalData = ICAL.parse(icalText);
const comp = new ICAL.Component(jCalData);
const vtz = comp.getFirstSubcomponent('vtimezone');
const tz = new ICAL.Timezone(vtz);
const tz = vtz != null ? new ICAL.Timezone(vtz) : null;
// Fetch the VEVENT part
comp.getAllSubcomponents('vevent').forEach(vevent => {
const event = new ICAL.Event(vevent);
event.startDate.zone = tz;
if (tz != null) {
event.startDate.zone = tz;
}
holidays = holidays.filter(holiday => !sameDay(new Date(holiday.date), event.startDate.toJSDate())); // remove if already exists
const holiday = eventToHoliday(event);

View File

@ -20,7 +20,7 @@ function readFile(input) {
const jCalData = ICAL.parse(icalText);
const comp = new ICAL.Component(jCalData);
const vtz = comp.getFirstSubcomponent('vtimezone');
const tz = new ICAL.Timezone(vtz);
const tz = vtz != null ? new ICAL.Timezone(vtz) : null;
// Fetch the VEVENT part
comp.getAllSubcomponents('vevent').forEach(vevent => {
@ -73,7 +73,9 @@ function getAlarmDefaults() {
}
function eventToAlarm(event, tz, offsetMs) {
event.startDate.zone = tz;
if (tz != null) {
event.startDate.zone = tz;
}
const dateOrig = event.startDate.toJSDate();
const date = offsetMs ? new Date(dateOrig - offsetMs) : dateOrig;