mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
Use Log.debug where applicable
This commit is contained in:
parent
3220702034
commit
0a58767563
@ -32,7 +32,6 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
|
|
||||||
let reloadTimer = null;
|
let reloadTimer = null;
|
||||||
let events = [];
|
let events = [];
|
||||||
let debug = false;
|
|
||||||
|
|
||||||
let fetchFailedCallback = function () {};
|
let fetchFailedCallback = function () {};
|
||||||
let eventsReceivedCallback = function () {};
|
let eventsReceivedCallback = function () {};
|
||||||
@ -216,7 +215,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dates = rule.between(pastLocal, futureLocal, true, limitFunction);
|
const dates = rule.between(pastLocal, futureLocal, true, limitFunction);
|
||||||
if (debug) Log.log("title=" + event.summary.val + " dates=" + JSON.stringify(dates));
|
Log.debug("title=" + event.summary.val + " dates=" + JSON.stringify(dates));
|
||||||
// The "dates" array contains the set of dates within our desired date range range that are valid
|
// The "dates" array contains the set of dates within our desired date range range that are valid
|
||||||
// for the recurrence rule. *However*, it's possible for us to have a specific recurrence that
|
// for the recurrence rule. *However*, it's possible for us to have a specific recurrence that
|
||||||
// had its date changed from outside the range to inside the range. For the time being,
|
// had its date changed from outside the range to inside the range. For the time being,
|
||||||
@ -246,18 +245,18 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
|
|
||||||
// for full day events, the time might be off from RRULE/Luxon problem
|
// for full day events, the time might be off from RRULE/Luxon problem
|
||||||
if (isFullDayEvent(event)) {
|
if (isFullDayEvent(event)) {
|
||||||
if (debug) Log.log("fullday");
|
Log.debug("fullday");
|
||||||
// if the offset is negative, east of GMT where the problem is
|
// if the offset is negative, east of GMT where the problem is
|
||||||
if (date.getTimezoneOffset() < 0) {
|
if (date.getTimezoneOffset() < 0) {
|
||||||
// get the offset of today when we are processing
|
// get the offset of today when we are processing
|
||||||
// this will be the correction we need to apply
|
// this will be the correction we need to apply
|
||||||
let nowOffset = new Date().getTimezoneOffset();
|
let nowOffset = new Date().getTimezoneOffset();
|
||||||
if (debug) Log.log("now offset is " + nowOffset);
|
Log.debug("now offset is " + nowOffset);
|
||||||
// reduce the time by the offset
|
// reduce the time by the offset
|
||||||
if (debug) Log.log(" recurring date is " + date + " offset is " + date.getTimezoneOffset());
|
Log.debug(" recurring date is " + date + " offset is " + date.getTimezoneOffset());
|
||||||
// apply the correction to the date/time to get it UTC relative
|
// apply the correction to the date/time to get it UTC relative
|
||||||
date = new Date(date.getTime() - Math.abs(nowOffset) * 60000);
|
date = new Date(date.getTime() - Math.abs(nowOffset) * 60000);
|
||||||
if (debug) Log.log("new recurring date is " + date);
|
Log.debug("new recurring date is " + date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startDate = moment(date);
|
startDate = moment(date);
|
||||||
@ -389,10 +388,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
let adjustHours = 0;
|
let adjustHours = 0;
|
||||||
// if a timezone was specified
|
// if a timezone was specified
|
||||||
if (!event.start.tz) {
|
if (!event.start.tz) {
|
||||||
if (debug) Log.log(" if no tz, guess based on now");
|
Log.debug(" if no tz, guess based on now");
|
||||||
event.start.tz = moment.tz.guess();
|
event.start.tz = moment.tz.guess();
|
||||||
}
|
}
|
||||||
if (debug) Log.log("initial tz=" + event.start.tz);
|
Log.debug("initial tz=" + event.start.tz);
|
||||||
|
|
||||||
// if there is a start date specified
|
// if there is a start date specified
|
||||||
if (event.start.tz) {
|
if (event.start.tz) {
|
||||||
@ -405,10 +404,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
if (tz) {
|
if (tz) {
|
||||||
// change the timezone to the IANA name
|
// change the timezone to the IANA name
|
||||||
event.start.tz = tz;
|
event.start.tz = tz;
|
||||||
// if(debug) Log.log("corrected timezone="+event.start.tz)
|
Log.debug("corrected timezone=" + event.start.tz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) Log.log("corrected tz=" + event.start.tz);
|
Log.debug("corrected tz=" + event.start.tz);
|
||||||
let mmo = 0; // offset from TZ string or calculated
|
let mmo = 0; // offset from TZ string or calculated
|
||||||
let mm = 0; // date with tz or offset
|
let mm = 0; // date with tz or offset
|
||||||
let mms = 0; // utc offset of created with tz
|
let mms = 0; // utc offset of created with tz
|
||||||
@ -417,45 +416,45 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
const regex = /[+|-]\d*:\d*/;
|
const regex = /[+|-]\d*:\d*/;
|
||||||
mmo = event.start.tz.match(regex).toString();
|
mmo = event.start.tz.match(regex).toString();
|
||||||
mms = mmo;
|
mms = mmo;
|
||||||
if (debug) Log.log("ical offset=" + mmo + " date=" + date);
|
Log.debug("ical offset=" + mmo + " date=" + date);
|
||||||
mm = moment(date);
|
mm = moment(date);
|
||||||
mm = mm.utcOffset(mmo);
|
mm = mm.utcOffset(mmo);
|
||||||
} else {
|
} else {
|
||||||
// get the start time in that timezone
|
// get the start time in that timezone
|
||||||
if (debug) Log.log("ttttttt=" + moment(event.start).toDate());
|
Log.debug("ttttttt=" + moment(event.start).toDate());
|
||||||
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);
|
Log.debug("ms offset=" + mms);
|
||||||
|
|
||||||
if (debug) Log.log("start date =" + moment.tz(moment(event.start), event.start.tz).toDate());
|
Log.debug("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
|
||||||
mm = moment.tz(moment(date), event.start.tz);
|
mm = moment.tz(moment(date), event.start.tz);
|
||||||
if (debug) Log.log("mm=" + mm.toDate());
|
Log.debug("mm=" + mm.toDate());
|
||||||
mmo = mm.utcOffset();
|
mmo = mm.utcOffset();
|
||||||
}
|
}
|
||||||
if (debug) Log.log("mm ofset=" + mmo + " hour=" + mm.format("H") + " event date=" + mm.toDate());
|
Log.debug("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 !== mms) {
|
if (mmo !== mms) {
|
||||||
// big offset
|
// big offset
|
||||||
if (debug) Log.log("offset");
|
Log.debug("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;
|
||||||
// if(debug) Log.log("adjusting date")
|
Log.debug("adjusting date");
|
||||||
}
|
}
|
||||||
if (Math.abs(mmo) > Math.abs(mms)) {
|
if (Math.abs(mmo) > Math.abs(mms)) {
|
||||||
adjustHours += 1;
|
adjustHours += 1;
|
||||||
if (debug) Log.log("adjust up 1 hour dst change");
|
Log.debug("adjust up 1 hour dst change");
|
||||||
} else if (Math.abs(mmo) < Math.abs(mms)) {
|
} else if (Math.abs(mmo) < Math.abs(mms)) {
|
||||||
adjustHours -= 1;
|
adjustHours -= 1;
|
||||||
if (debug) Log.log("adjust down 1 hour dst change");
|
Log.debug("adjust down 1 hour dst change");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) Log.log("adjustHours=" + adjustHours);
|
Log.debug("adjustHours=" + adjustHours);
|
||||||
return adjustHours;
|
return adjustHours;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user