Skip to content

Commit

Permalink
sched/calendar interface: fix null timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
nxdefiant committed Dec 10, 2023
1 parent e513b90 commit c815168
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions apps/calendar/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
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);
Expand Down
6 changes: 4 additions & 2 deletions apps/sched/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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 => {
Expand Down Expand Up @@ -73,7 +73,9 @@
}

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;

Expand Down

0 comments on commit c815168

Please sign in to comment.