diff --git a/apps/calendar/interface.html b/apps/calendar/interface.html
index 280a96c0b..ea64632f8 100644
--- a/apps/calendar/interface.html
+++ b/apps/calendar/interface.html
@@ -28,11 +28,16 @@ function readFile(input) {
for(let i=0; i {
- const jCalData = ICAL.parse(reader.result);
+ const icalText = reader.result.substring(reader.result.indexOf("BEGIN:VCALENDAR")); // remove html before data
+ const jCalData = ICAL.parse(icalText);
const comp = new ICAL.Component(jCalData);
+ const vtz = comp.getFirstSubcomponent('vtimezone');
+ const tz = new ICAL.Timezone(vtz);
+
// Fetch the VEVENT part
comp.getAllSubcomponents('vevent').forEach(vevent => {
- event = new ICAL.Event(vevent);
+ const event = new ICAL.Event(vevent);
+ event.startDate.zone = tz;
holidays = holidays.filter(holiday => !sameDay(new Date(holiday.date), event.startDate.toJSDate())); // remove if already exists
const holiday = eventToHoliday(event);
diff --git a/apps/sched/interface.html b/apps/sched/interface.html
index cd2c9c595..53b443371 100644
--- a/apps/sched/interface.html
+++ b/apps/sched/interface.html
@@ -16,14 +16,18 @@ function readFile(input) {
for(let i=0; i {
- const jCalData = ICAL.parse(reader.result);
+ const icalText = reader.result.substring(reader.result.indexOf("BEGIN:VCALENDAR")); // remove html before data
+ const jCalData = ICAL.parse(icalText);
const comp = new ICAL.Component(jCalData);
+ const vtz = comp.getFirstSubcomponent('vtimezone');
+ const tz = new ICAL.Timezone(vtz);
+
// Fetch the VEVENT part
comp.getAllSubcomponents('vevent').forEach(vevent => {
event = new ICAL.Event(vevent);
const exists = alarms.some(alarm => alarm.id === event.uid);
- const alarm = eventToAlarm(event, offsetMinutes*60*1000);
+ const alarm = eventToAlarm(event, tz, offsetMinutes*60*1000);
renderAlarm(alarm, exists);
if (exists) {
@@ -68,7 +72,8 @@ function getAlarmDefaults() {
};
}
-function eventToAlarm(event, offsetMs) {
+function eventToAlarm(event, tz, offsetMs) {
+ event.startDate.zone = tz;
const dateOrig = event.startDate.toJSDate();
const date = offsetMs ? new Date(dateOrig - offsetMs) : dateOrig;