diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index c12dfb1d..b7f89b1d 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -236,7 +236,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn // Loop through the set of date entries to see which recurrences should be added to our event list. for (let d in dates) { - const date = dates[d]; + let date = dates[d]; // ical.js started returning recurrences and exdates as ISOStrings without time information. // .toISOString().substring(0,10) is the method they use to calculate keys, so we'll do the same // (see https://github.com/peterbraden/ical.js/pull/84 ) @@ -409,24 +409,30 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } } if (debug) Log.log("corrected tz=" + event.start.tz); + let mmo = 0; // offset from TZ string or calculated + let mm = 0; // date with tz or offset + let mms = 0; // utc offset of created with tz // if there is still an offset, lookup failed, use it if (event.start.tz.startsWith("(")) { const regex = /[+|-]\d*:\d*/; - offset = event.start.tz.match(regex).toString(); - if (debug) Log.log("ical offset=" + offset); + mms=mmo = event.start.tz.match(regex).toString(); + if (debug) Log.log("ical offset=" + mmo); + mm = moment.tz(moment(date)); + mm.utcOffset(mmo) } + else { + // get the start time in that timezone + if (debug) Log.log("ttttttt=" + moment(event.start).toDate()); + mms = moment.tz(moment(event.start), event.start.tz).utcOffset(); + if (debug) Log.log("ms offset=" + mms); - // get the start time in that timezone - if (debug) Log.log("ttttttt=" + moment(event.start).toDate()); - let mms = moment.tz(moment(event.start), event.start.tz).utcOffset(); - if (debug) Log.log("ms offset=" + mms); + if (debug) Log.log("start date =" + moment.tz(moment(event.start), event.start.tz).toDate()); - if (debug) Log.log("start date =" + moment.tz(moment(event.start), event.start.tz).toDate()); - - // get the specified date in that timezone - let mm = moment.tz(moment(date), event.start.tz); - if (debug) Log.log("mm=" + mm.toDate()); - let mmo = mm.utcOffset(); + // get the specified date in that timezone + mm = moment.tz(moment(date), event.start.tz); + if (debug) Log.log("mm=" + mm.toDate()); + mmo = mm.utcOffset(); + } if (debug) Log.log("mm ofset=" + mmo + " hour=" + mm.format("H") + " event date=" + mm.toDate()); // if the offset is greater than 0, east of london if (mmo > 0) { @@ -434,7 +440,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn if (debug) Log.log("offset"); let h = parseInt(mm.format("H")); // check if the event time is less than the offset - if (h > 0 && h < Math.abs(mmo) / 60) { + if (h > 0 && h < (Math.abs(mmo) / 60)) { // if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time) // we need to fix that adjustHours = 24;