mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
fix time adjustment routine
This commit is contained in:
parent
8466ff0c1a
commit
b73cfd8a60
@ -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.
|
// Loop through the set of date entries to see which recurrences should be added to our event list.
|
||||||
for (let d in dates) {
|
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.
|
// 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
|
// .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 )
|
// (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);
|
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 there is still an offset, lookup failed, use it
|
||||||
if (event.start.tz.startsWith("(")) {
|
if (event.start.tz.startsWith("(")) {
|
||||||
const regex = /[+|-]\d*:\d*/;
|
const regex = /[+|-]\d*:\d*/;
|
||||||
offset = event.start.tz.match(regex).toString();
|
mms=mmo = event.start.tz.match(regex).toString();
|
||||||
if (debug) Log.log("ical offset=" + offset);
|
if (debug) Log.log("ical offset=" + mmo);
|
||||||
|
mm = moment.tz(moment(date));
|
||||||
|
mm.utcOffset(mmo)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// get the start time in that timezone
|
// get the start time in that timezone
|
||||||
if (debug) Log.log("ttttttt=" + moment(event.start).toDate());
|
if (debug) Log.log("ttttttt=" + moment(event.start).toDate());
|
||||||
let mms = moment.tz(moment(event.start), event.start.tz).utcOffset();
|
mms = moment.tz(moment(event.start), event.start.tz).utcOffset();
|
||||||
if (debug) Log.log("ms offset=" + mms);
|
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
|
// get the specified date in that timezone
|
||||||
let mm = moment.tz(moment(date), event.start.tz);
|
mm = moment.tz(moment(date), event.start.tz);
|
||||||
if (debug) Log.log("mm=" + mm.toDate());
|
if (debug) Log.log("mm=" + mm.toDate());
|
||||||
let mmo = mm.utcOffset();
|
mmo = mm.utcOffset();
|
||||||
|
}
|
||||||
if (debug) Log.log("mm ofset=" + mmo + " hour=" + mm.format("H") + " event date=" + mm.toDate());
|
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 the offset is greater than 0, east of london
|
||||||
if (mmo > 0) {
|
if (mmo > 0) {
|
||||||
@ -434,7 +440,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
if (debug) Log.log("offset");
|
if (debug) Log.log("offset");
|
||||||
let h = parseInt(mm.format("H"));
|
let h = parseInt(mm.format("H"));
|
||||||
// check if the event time is less than the offset
|
// 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)
|
// if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time)
|
||||||
// we need to fix that
|
// we need to fix that
|
||||||
adjustHours = 24;
|
adjustHours = 24;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user