mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +00:00
change debug logging from console. to Log.
This commit is contained in:
parent
1e0fc7eb0d
commit
8466ff0c1a
@ -111,7 +111,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
if (event.type === "VEVENT") {
|
||||
let startDate = eventDate(event, "start");
|
||||
let endDate;
|
||||
// console.log("\nevent="+JSON.stringify(event))
|
||||
// Log.log("\nevent="+JSON.stringify(event))
|
||||
if (typeof event.end !== "undefined") {
|
||||
endDate = eventDate(event, "end");
|
||||
} else if (typeof event.duration !== "undefined") {
|
||||
@ -216,7 +216,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
}
|
||||
|
||||
const dates = rule.between(pastLocal, futureLocal, true, limitFunction);
|
||||
if (debug) console.log("title=" + event.summary.val + " dates=" + JSON.stringify(dates));
|
||||
if (debug) Log.log("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
|
||||
// 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,
|
||||
@ -246,18 +246,18 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
|
||||
// for full day events, the time might be off from RRULE/Luxon problem
|
||||
if (isFullDayEvent(event)) {
|
||||
if (debug) console.log("fullday");
|
||||
if (debug) Log.log("fullday");
|
||||
// if the offset is negative, east of GMT where the problem is
|
||||
if (date.getTimezoneOffset() < 0) {
|
||||
// get the offset of today when we are processing
|
||||
// this will be the correction we need to apply
|
||||
let nowOffset = new Date().getTimezoneOffset();
|
||||
if (debug) console.log("now offset is " + nowOffset);
|
||||
if (debug) Log.log("now offset is " + nowOffset);
|
||||
// reduce the time by the offset
|
||||
if (debug) console.log(" recurring date is " + date + " offset is " + date.getTimezoneOffset());
|
||||
if (debug) Log.log(" recurring date is " + date + " offset is " + date.getTimezoneOffset());
|
||||
// apply the correction to the date/time to get it UTC relative
|
||||
date = new Date(date.getTime() - Math.abs(nowOffset) * 60000);
|
||||
if (debug) console.log("new recurring date is " + date);
|
||||
if (debug) Log.log("new recurring date is " + date);
|
||||
}
|
||||
}
|
||||
startDate = moment(date);
|
||||
@ -277,7 +277,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
showRecurrence = false;
|
||||
}
|
||||
|
||||
//console.log("duration="+duration)
|
||||
//Log.log("duration="+duration)
|
||||
|
||||
endDate = moment(parseInt(startDate.format("x")) + duration, "x");
|
||||
if (startDate.format("x") === endDate.format("x")) {
|
||||
@ -316,7 +316,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
} else {
|
||||
// Single event.
|
||||
const fullDayEvent = isFacebookBirthday ? true : isFullDayEvent(event);
|
||||
// console.log("full day event")
|
||||
// Log.log("full day event")
|
||||
if (includePastEvents) {
|
||||
// Past event is too far in the past, so skip.
|
||||
if (endDate < past) {
|
||||
@ -349,7 +349,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
}
|
||||
// if the start and end are the same, then make end the 'end of day' value (start is at 00:00:00)
|
||||
if (fullDayEvent && startDate.format("x") === endDate.format("x")) {
|
||||
//console.log("end same as start")
|
||||
//Log.log("end same as start")
|
||||
endDate = endDate.endOf("day");
|
||||
}
|
||||
// get correction for date saving and dst change between now and then
|
||||
@ -389,10 +389,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
let adjustHours = 0;
|
||||
// if a timezone was specified
|
||||
if (!event.start.tz) {
|
||||
if (debug) console.log(" if no tz, guess based on now");
|
||||
if (debug) Log.log(" if no tz, guess based on now");
|
||||
event.start.tz = moment.tz.guess();
|
||||
}
|
||||
if (debug) console.log("initial tz=" + event.start.tz);
|
||||
if (debug) Log.log("initial tz=" + event.start.tz);
|
||||
|
||||
// if there is a start date specified
|
||||
if (event.start.tz) {
|
||||
@ -405,51 +405,51 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
||||
if (tz) {
|
||||
// change the timezone to the IANA name
|
||||
event.start.tz = tz;
|
||||
// if(debug) console.log("corrected timezone="+event.start.tz)
|
||||
// if(debug) Log.log("corrected timezone="+event.start.tz)
|
||||
}
|
||||
}
|
||||
if (debug) console.log("corrected tz=" + event.start.tz);
|
||||
if (debug) Log.log("corrected tz=" + event.start.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) console.log("ical offset=" + offset);
|
||||
if (debug) Log.log("ical offset=" + offset);
|
||||
}
|
||||
|
||||
// get the start time in that timezone
|
||||
if (debug) console.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();
|
||||
if (debug) console.log("ms offset=" + mms);
|
||||
if (debug) Log.log("ms offset=" + mms);
|
||||
|
||||
if (debug) console.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) console.log("mm=" + mm.toDate());
|
||||
if (debug) Log.log("mm=" + mm.toDate());
|
||||
let mmo = mm.utcOffset();
|
||||
if (debug) console.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 (mmo > 0) {
|
||||
// big offset
|
||||
if (debug) console.log("offset");
|
||||
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 so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time)
|
||||
// we need to fix that
|
||||
adjustHours = 24;
|
||||
// if(debug) console.log("adjusting date")
|
||||
// if(debug) Log.log("adjusting date")
|
||||
}
|
||||
if (mmo > mms) {
|
||||
adjustHours += 1;
|
||||
if (debug) console.log("adjust up 1 hour dst change");
|
||||
if (debug) Log.log("adjust up 1 hour dst change");
|
||||
} else if (mmo < mms) {
|
||||
adjustHours -= 1;
|
||||
if (debug) console.log("adjust down 1 hour dst change");
|
||||
if (debug) Log.log("adjust down 1 hour dst change");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) console.log("adjustHours=" + adjustHours);
|
||||
if (debug) Log.log("adjustHours=" + adjustHours);
|
||||
return adjustHours;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user