From 6ec0aa88948e24f11dbe4e50a442a96db1089079 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 1 Oct 2020 12:19:57 +0200 Subject: [PATCH 01/39] Prepare 2.14.0-develop --- CHANGELOG.md | 12 ++++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae705..08610111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ This project adheres to [Semantic Versioning](https://semver.org/). ❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² +## [2.14.0] - Unreleased (Develop Branch) + +_This release is scheduled to be released on 2021-01-01._ + +### Added + +### Updated + +### Deleted + +### Fixed + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. diff --git a/package-lock.json b/package-lock.json index 01c38c4d..204e37a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "magicmirror", - "version": "2.13.0", + "version": "2.14.0-develop", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5e4de9ac..8178fba3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "magicmirror", - "version": "2.13.0", + "version": "2.14.0-develop", "description": "The open source modular smart mirror platform.", "main": "js/electron.js", "scripts": { From 04dae52a6ca82a0d754a788b5576e7d9c77ee290 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 4 Oct 2020 12:10:19 -0500 Subject: [PATCH 02/39] correct daylight/standard adjustments, windows timezones and east of london rrule bug --- modules/default/calendar/calendarfetcher.js | 63 ++++++++- modules/default/calendar/windowsZones.json | 139 ++++++++++++++++++++ 2 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 modules/default/calendar/windowsZones.json diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 964cb955..bb3c4daa 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -242,6 +242,45 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let showRecurrence = true; startDate = moment(date); + // whether we need to adjust for RRULE returning the wrong date, with the right time (forward of URC timezones) + let adjustHours = 0; + // if a timezone was specified + if (!event.start.tz) { + // guess at one + event.start.tz = moment.tz.guess(); + } + // if there is a timezone + if (event.start.tz) { + // if it contains a space, it is windows, + if (event.start.tz.indexOf(" ") > 0) { + // get the IANA name string from hash + event.start.tz = getIanaTZFromMS(event.start.tz); + } + // get the offset of the start date/time + let mms = moment.tz(moment(event.start), event.start.tz).utcOffset(); + // get the specified recurring date/time in that timezone + let mm = moment.tz(moment(date), event.start.tz); + // and its offset + let mmo = mm.utcOffset(); + // if the offset is greater than 0, east of london + if (mmo > 0) { + // get the hour for the recurring date/time + let h = parseInt(mm.format("H")); + // check if the event time is less than the offset + if (h > 0 && h < mmo / 60) { + // if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time) + // we need to fix that + adjustHours = 24; + } + // did the daylight savings offset change from start to now? + // fix it + if (mmo > mms) { + adjustHours += 1; + } else if (mmo < mms) { + adjustHours -= 1; + } + } + } // For each date that we're checking, it's possible that there is a recurrence override for that one day. if (curEvent.recurrences !== undefined && curEvent.recurrences[dateKey] !== undefined) { @@ -277,8 +316,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn addedEvents++; newEvents.push({ title: recurrenceTitle, - startDate: startDate.format("x"), - endDate: endDate.format("x"), + startDate: (adjustHours ? startDate.subtract(adjustHours, "hours") : startDate).format("x"), + endDate: (adjustHours ? endDate.subtract(adjustHours, "hours") : endDate).format("x"), fullDayEvent: isFullDayEvent(event), recurringEvent: true, class: event.class, @@ -324,6 +363,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn if (fullDayEvent && startDate <= today) { startDate = moment(today); } + // 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")) { + endDate = endDate.endOf("day"); + } // Every thing is good. Add it to the list. newEvents.push({ @@ -351,6 +394,22 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }); }; + /** + * + * lookup iana tz from windows + */ + let zoneTable = null; + const getIanaTZFromMS = function (msTZName) { + if (!zoneTable) { + const p = require("path"); + zoneTable = require(p.join(__dirname, "windowsZones.json")); + } + // Get hash entry + const he = zoneTable[msTZName]; + // If found return iana name, else null + return he ? he.iana[0] : null; + }; + /** * Schedule the timer for the next update. */ diff --git a/modules/default/calendar/windowsZones.json b/modules/default/calendar/windowsZones.json new file mode 100644 index 00000000..2e6bd6b3 --- /dev/null +++ b/modules/default/calendar/windowsZones.json @@ -0,0 +1,139 @@ +{ + "Dateline Standard Time": { "iana": ["Etc/GMT+12"] }, + "UTC-11": { "iana": ["Etc/GMT+11"] }, + "Aleutian Standard Time": { "iana": ["America/Adak"] }, + "Hawaiian Standard Time": { "iana": ["Pacific/Honolulu"] }, + "Marquesas Standard Time": { "iana": ["Pacific/Marquesas"] }, + "Alaskan Standard Time": { "iana": ["America/Anchorage"] }, + "UTC-09": { "iana": ["Etc/GMT+9"] }, + "Pacific Standard Time (Mexico)": { "iana": ["America/Tijuana"] }, + "UTC-08": { "iana": ["Etc/GMT+8"] }, + "Pacific Standard Time": { "iana": ["America/Los_Angeles"] }, + "US Mountain Standard Time": { "iana": ["America/Phoenix"] }, + "Mountain Standard Time (Mexico)": { "iana": ["America/Chihuahua"] }, + "Mountain Standard Time": { "iana": ["America/Denver"] }, + "Central America Standard Time": { "iana": ["America/Guatemala"] }, + "Central Standard Time": { "iana": ["America/Chicago"] }, + "Easter Island Standard Time": { "iana": ["Pacific/Easter"] }, + "Central Standard Time (Mexico)": { "iana": ["America/Mexico_City"] }, + "Canada Central Standard Time": { "iana": ["America/Regina"] }, + "SA Pacific Standard Time": { "iana": ["America/Bogota"] }, + "Eastern Standard Time (Mexico)": { "iana": ["America/Cancun"] }, + "Eastern Standard Time": { "iana": ["America/New_York"] }, + "Haiti Standard Time": { "iana": ["America/Port-au-Prince"] }, + "Cuba Standard Time": { "iana": ["America/Havana"] }, + "US Eastern Standard Time": { "iana": ["America/Indianapolis"] }, + "Turks And Caicos Standard Time": { "iana": ["America/Grand_Turk"] }, + "Paraguay Standard Time": { "iana": ["America/Asuncion"] }, + "Atlantic Standard Time": { "iana": ["America/Halifax"] }, + "Venezuela Standard Time": { "iana": ["America/Caracas"] }, + "Central Brazilian Standard Time": { "iana": ["America/Cuiaba"] }, + "SA Western Standard Time": { "iana": ["America/La_Paz"] }, + "Pacific SA Standard Time": { "iana": ["America/Santiago"] }, + "Newfoundland Standard Time": { "iana": ["America/St_Johns"] }, + "Tocantins Standard Time": { "iana": ["America/Araguaina"] }, + "E. South America Standard Time": { "iana": ["America/Sao_Paulo"] }, + "SA Eastern Standard Time": { "iana": ["America/Cayenne"] }, + "Argentina Standard Time": { "iana": ["America/Buenos_Aires"] }, + "Greenland Standard Time": { "iana": ["America/Godthab"] }, + "Montevideo Standard Time": { "iana": ["America/Montevideo"] }, + "Magallanes Standard Time": { "iana": ["America/Punta_Arenas"] }, + "Saint Pierre Standard Time": { "iana": ["America/Miquelon"] }, + "Bahia Standard Time": { "iana": ["America/Bahia"] }, + "UTC-02": { "iana": ["Etc/GMT+2"] }, + "Azores Standard Time": { "iana": ["Atlantic/Azores"] }, + "Cape Verde Standard Time": { "iana": ["Atlantic/Cape_Verde"] }, + "UTC": { "iana": ["Etc/GMT"] }, + "GMT Standard Time": { "iana": ["Europe/London"] }, + "Greenwich Standard Time": { "iana": ["Atlantic/Reykjavik"] }, + "Sao Tome Standard Time": { "iana": ["Africa/Sao_Tome"] }, + "Morocco Standard Time": { "iana": ["Africa/Casablanca"] }, + "W. Europe Standard Time": { "iana": ["Europe/Berlin"] }, + "Central Europe Standard Time": { "iana": ["Europe/Budapest"] }, + "Romance Standard Time": { "iana": ["Europe/Paris"] }, + "Central European Standard Time": { "iana": ["Europe/Warsaw"] }, + "W. Central Africa Standard Time": { "iana": ["Africa/Lagos"] }, + "Jordan Standard Time": { "iana": ["Asia/Amman"] }, + "GTB Standard Time": { "iana": ["Europe/Bucharest"] }, + "Middle East Standard Time": { "iana": ["Asia/Beirut"] }, + "Egypt Standard Time": { "iana": ["Africa/Cairo"] }, + "E. Europe Standard Time": { "iana": ["Europe/Chisinau"] }, + "Syria Standard Time": { "iana": ["Asia/Damascus"] }, + "West Bank Standard Time": { "iana": ["Asia/Hebron"] }, + "South Africa Standard Time": { "iana": ["Africa/Johannesburg"] }, + "FLE Standard Time": { "iana": ["Europe/Kiev"] }, + "Israel Standard Time": { "iana": ["Asia/Jerusalem"] }, + "Kaliningrad Standard Time": { "iana": ["Europe/Kaliningrad"] }, + "Sudan Standard Time": { "iana": ["Africa/Khartoum"] }, + "Libya Standard Time": { "iana": ["Africa/Tripoli"] }, + "Namibia Standard Time": { "iana": ["Africa/Windhoek"] }, + "Arabic Standard Time": { "iana": ["Asia/Baghdad"] }, + "Turkey Standard Time": { "iana": ["Europe/Istanbul"] }, + "Arab Standard Time": { "iana": ["Asia/Riyadh"] }, + "Belarus Standard Time": { "iana": ["Europe/Minsk"] }, + "Russian Standard Time": { "iana": ["Europe/Moscow"] }, + "E. Africa Standard Time": { "iana": ["Africa/Nairobi"] }, + "Iran Standard Time": { "iana": ["Asia/Tehran"] }, + "Arabian Standard Time": { "iana": ["Asia/Dubai"] }, + "Astrakhan Standard Time": { "iana": ["Europe/Astrakhan"] }, + "Azerbaijan Standard Time": { "iana": ["Asia/Baku"] }, + "Russia Time Zone 3": { "iana": ["Europe/Samara"] }, + "Mauritius Standard Time": { "iana": ["Indian/Mauritius"] }, + "Saratov Standard Time": { "iana": ["Europe/Saratov"] }, + "Georgian Standard Time": { "iana": ["Asia/Tbilisi"] }, + "Volgograd Standard Time": { "iana": ["Europe/Volgograd"] }, + "Caucasus Standard Time": { "iana": ["Asia/Yerevan"] }, + "Afghanistan Standard Time": { "iana": ["Asia/Kabul"] }, + "West Asia Standard Time": { "iana": ["Asia/Tashkent"] }, + "Ekaterinburg Standard Time": { "iana": ["Asia/Yekaterinburg"] }, + "Pakistan Standard Time": { "iana": ["Asia/Karachi"] }, + "Qyzylorda Standard Time": { "iana": ["Asia/Qyzylorda"] }, + "India Standard Time": { "iana": ["Asia/Calcutta"] }, + "Sri Lanka Standard Time": { "iana": ["Asia/Colombo"] }, + "Nepal Standard Time": { "iana": ["Asia/Katmandu"] }, + "Central Asia Standard Time": { "iana": ["Asia/Almaty"] }, + "Bangladesh Standard Time": { "iana": ["Asia/Dhaka"] }, + "Omsk Standard Time": { "iana": ["Asia/Omsk"] }, + "Myanmar Standard Time": { "iana": ["Asia/Rangoon"] }, + "SE Asia Standard Time": { "iana": ["Asia/Bangkok"] }, + "Altai Standard Time": { "iana": ["Asia/Barnaul"] }, + "W. Mongolia Standard Time": { "iana": ["Asia/Hovd"] }, + "North Asia Standard Time": { "iana": ["Asia/Krasnoyarsk"] }, + "N. Central Asia Standard Time": { "iana": ["Asia/Novosibirsk"] }, + "Tomsk Standard Time": { "iana": ["Asia/Tomsk"] }, + "China Standard Time": { "iana": ["Asia/Shanghai"] }, + "North Asia East Standard Time": { "iana": ["Asia/Irkutsk"] }, + "Singapore Standard Time": { "iana": ["Asia/Singapore"] }, + "W. Australia Standard Time": { "iana": ["Australia/Perth"] }, + "Taipei Standard Time": { "iana": ["Asia/Taipei"] }, + "Ulaanbaatar Standard Time": { "iana": ["Asia/Ulaanbaatar"] }, + "Aus Central W. Standard Time": { "iana": ["Australia/Eucla"] }, + "Transbaikal Standard Time": { "iana": ["Asia/Chita"] }, + "Tokyo Standard Time": { "iana": ["Asia/Tokyo"] }, + "North Korea Standard Time": { "iana": ["Asia/Pyongyang"] }, + "Korea Standard Time": { "iana": ["Asia/Seoul"] }, + "Yakutsk Standard Time": { "iana": ["Asia/Yakutsk"] }, + "Cen. Australia Standard Time": { "iana": ["Australia/Adelaide"] }, + "AUS Central Standard Time": { "iana": ["Australia/Darwin"] }, + "E. Australia Standard Time": { "iana": ["Australia/Brisbane"] }, + "AUS Eastern Standard Time": { "iana": ["Australia/Sydney"] }, + "West Pacific Standard Time": { "iana": ["Pacific/Port_Moresby"] }, + "Tasmania Standard Time": { "iana": ["Australia/Hobart"] }, + "Vladivostok Standard Time": { "iana": ["Asia/Vladivostok"] }, + "Lord Howe Standard Time": { "iana": ["Australia/Lord_Howe"] }, + "Bougainville Standard Time": { "iana": ["Pacific/Bougainville"] }, + "Russia Time Zone 10": { "iana": ["Asia/Srednekolymsk"] }, + "Magadan Standard Time": { "iana": ["Asia/Magadan"] }, + "Norfolk Standard Time": { "iana": ["Pacific/Norfolk"] }, + "Sakhalin Standard Time": { "iana": ["Asia/Sakhalin"] }, + "Central Pacific Standard Time": { "iana": ["Pacific/Guadalcanal"] }, + "Russia Time Zone 11": { "iana": ["Asia/Kamchatka"] }, + "New Zealand Standard Time": { "iana": ["Pacific/Auckland"] }, + "UTC+12": { "iana": ["Etc/GMT-12"] }, + "Fiji Standard Time": { "iana": ["Pacific/Fiji"] }, + "Chatham Islands Standard Time": { "iana": ["Pacific/Chatham"] }, + "UTC+13": { "iana": ["Etc/GMT-13"] }, + "Tonga Standard Time": { "iana": ["Pacific/Tongatapu"] }, + "Samoa Standard Time": { "iana": ["Pacific/Apia"] }, + "Line Islands Standard Time": { "iana": ["Pacific/Kiritimati"] } +} From 8fa96c2836d0fee0a6d68e990587a1e2d0ba3cd3 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 4 Oct 2020 12:13:08 -0500 Subject: [PATCH 03/39] add error handler to json parsing of translation files --- js/translator.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/translator.js b/js/translator.js index 0f4bc00a..43b65297 100644 --- a/js/translator.js +++ b/js/translator.js @@ -19,7 +19,15 @@ var Translator = (function () { xhr.open("GET", file, true); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { - callback(JSON.parse(xhr.responseText)); + // needs error handler try/catch at least + let fileinfo = null; + try { + fileinfo = JSON.parse(xhr.responseText); + } catch (exception) { + // nothing here, but don't die + console.log(" loading json file failed =" + file); + } + callback(fileinfo); } }; xhr.send(null); From eefb92367e0db8715df9a8560760953ce35a07ea Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 10:02:29 -0500 Subject: [PATCH 04/39] fix node-ical version --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 01c38c4d..f36422af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5723,9 +5723,9 @@ "dev": true }, "node-ical": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/node-ical/-/node-ical-0.12.0.tgz", - "integrity": "sha512-whPA/GABFAWMVzqKeTuBjzPGCfNR9eoCSWPHE6MkHyDlQqScdVfyWr0dRy50Lvfz9JCNqFqiko1GpHJ21pn8YA==", + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/node-ical/-/node-ical-0.12.1.tgz", + "integrity": "sha512-1YlvRyfOs0fUr8KWtgj4r/4VMI0tuBLfVSyrmDk00jLuUkXouiSU0PptEGdJs3U3pibF8ZThU6rVVS/jkcXJBQ==", "requires": { "moment-timezone": "^0.5.31", "request": "^2.88.2", diff --git a/package.json b/package.json index 5e4de9ac..e52d99dd 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "iconv-lite": "^0.6.2", "module-alias": "^2.2.2", "moment": "^2.28.0", - "node-ical": "^0.12.0", + "node-ical": "^0.12.1", "request": "^2.88.2", "rrule": "^2.6.6", "rrule-alt": "^2.2.8", From 69efca0bdbfb0e088ca122098e2449d484abbfd6 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 10:45:07 -0500 Subject: [PATCH 05/39] use Log.error instead of console.log for error message, shows in output --- js/translator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/translator.js b/js/translator.js index 43b65297..5dc50045 100644 --- a/js/translator.js +++ b/js/translator.js @@ -25,7 +25,7 @@ var Translator = (function () { fileinfo = JSON.parse(xhr.responseText); } catch (exception) { // nothing here, but don't die - console.log(" loading json file failed =" + file); + Log.error(" loading json file =" + file + " failed"); } callback(fileinfo); } From 2e981987f24bed2abc6bbbcc9a5437ae0c018fad Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 11:06:21 -0500 Subject: [PATCH 06/39] resolve conflict --- modules/default/calendar/calendarfetcher.js | 52 +++++++++++++-------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index bb3c4daa..f153f7c0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -110,7 +110,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)) if (typeof event.end !== "undefined") { endDate = eventDate(event, "end"); } else if (typeof event.duration !== "undefined") { @@ -212,8 +212,9 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn pastLocal = pastMoment.subtract(past.getTimezoneOffset(), "minutes").toDate(); futureLocal = futureMoment.subtract(future.getTimezoneOffset(), "minutes").toDate(); } - const dates = rule.between(pastLocal, futureLocal, true, limitFunction); + const dates = rule.between(pastLocal, futureLocal, true, limitFunction); + // console.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, @@ -242,42 +243,50 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let showRecurrence = true; startDate = moment(date); + // console.log("now timezone="+ moment.tz.guess()); // whether we need to adjust for RRULE returning the wrong date, with the right time (forward of URC timezones) - let adjustHours = 0; + let adjustDays = 0; // if a timezone was specified if (!event.start.tz) { - // guess at one event.start.tz = moment.tz.guess(); } - // if there is a timezone + // console.log("tz="+event.start.tz) if (event.start.tz) { - // if it contains a space, it is windows, + // if this is a windows timezone if (event.start.tz.indexOf(" ") > 0) { - // get the IANA name string from hash - event.start.tz = getIanaTZFromMS(event.start.tz); + // use the lookup table to get theIANA name as moment and date don't know MS timezones + let tz = getIanaTZFromMS(event.start.tz); + // watch out for unregistered windows timezone names + // if we had a successfule lookup + if (tz) { + // change the timezone to the IANA name + event.start.tz = getIanaTZFromMS(event.start.tz); + // console.log("corrected timezone="+event.start.tz) + } } - // get the offset of the start date/time + // get the start time in that timezone let mms = moment.tz(moment(event.start), event.start.tz).utcOffset(); - // get the specified recurring date/time in that timezone + // console.log("ms offset="+mms) + // get the specified date in that timezone let mm = moment.tz(moment(date), event.start.tz); - // and its offset let mmo = mm.utcOffset(); + // console.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) { - // get the hour for the recurring date/time let h = parseInt(mm.format("H")); // check if the event time is less than the offset if (h > 0 && h < mmo / 60) { // if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time) // we need to fix that - adjustHours = 24; + adjustDays = 24; + // console.log("adjusting date") } - // did the daylight savings offset change from start to now? - // fix it if (mmo > mms) { - adjustHours += 1; + adjustDays += 1; + // console.log("adjust up 1 hour dst change") } else if (mmo < mms) { - adjustHours -= 1; + adjustDays -= 1; + //console.log("adjust down 1 hour dst change") } } } @@ -295,6 +304,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn showRecurrence = false; } + //console.log("duration="+duration) + endDate = moment(parseInt(startDate.format("x")) + duration, "x"); if (startDate.format("x") === endDate.format("x")) { endDate = endDate.endOf("day"); @@ -316,8 +327,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn addedEvents++; newEvents.push({ title: recurrenceTitle, - startDate: (adjustHours ? startDate.subtract(adjustHours, "hours") : startDate).format("x"), - endDate: (adjustHours ? endDate.subtract(adjustHours, "hours") : endDate).format("x"), + startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"), + endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"), fullDayEvent: isFullDayEvent(event), recurringEvent: true, class: event.class, @@ -332,7 +343,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } else { // Single event. const fullDayEvent = isFacebookBirthday ? true : isFullDayEvent(event); - + // console.log("full day event") if (includePastEvents) { // Past event is too far in the past, so skip. if (endDate < past) { @@ -365,6 +376,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") endDate = endDate.endOf("day"); } From 11afadcea86742515323f9ef926576899f576710 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 12:56:25 -0500 Subject: [PATCH 07/39] fix RRULE bad date and add Windows Timezone name support --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae705..8465927e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](https://semver.org/). ❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² +### Fixed + +- Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. From 6440d2289c22b4a02d740d1801ab9fba566c5696 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 12:58:10 -0500 Subject: [PATCH 08/39] fix translation files with comments crashing UI --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae705..246effd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](https://semver.org/). ❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² +### Fixed + +- JSON Parse translation files with comments crashing UI + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. From 52edec1b64f9295b31aec22ea3b7753d40758b58 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 5 Oct 2020 12:59:30 -0500 Subject: [PATCH 09/39] fix wrong node-ical version requested, package.json --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae705..a9ff0ca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](https://semver.org/). ❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² +### Fixed + +- wrong node-ical version installed (package.json requested version) + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. From 1bc0270d7bda950380702c81bf3c2e04073b8483 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Sun, 11 Oct 2020 09:36:52 +0200 Subject: [PATCH 10/39] Update forecast.njk change name of day to today and tomorrow --- modules/default/weather/forecast.njk | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index 7d0f515d..98569e23 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -10,19 +10,25 @@ {% set forecast = forecast.slice(0, numSteps) %} {% for f in forecast %} + {% if (currentStep == 0) %} + {{ "TODAY" | translate }} + {% elif (currentStep == 1) %} + {{ "TOMORROW" | translate }} + {% else %} {{ f.date.format('ddd') }} - - - {{ f.maxTemperature | roundValue | unit("temperature") }} - - - {{ f.minTemperature | roundValue | unit("temperature") }} - - {% if config.showPrecipitationAmount %} - - {{ f.precipitation | unit("precip") }} - - {% endif %} + {% endif %} + + + {{ f.maxTemperature | roundValue | unit("temperature") }} + + + {{ f.minTemperature | roundValue | unit("temperature") }} + + {% if config.showPrecipitationAmount %} + + {{ f.precipitation | unit("precip") }} + + {% endif %} {% set currentStep = currentStep + 1 %} {% endfor %} From 569dec1b0b60a96e8fecbd4a33032aaddc7210c1 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Sun, 11 Oct 2020 09:42:09 +0200 Subject: [PATCH 11/39] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb61bd24..ce7a75a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ _This release is scheduled to be released on 2021-01-01._ ### Added ### Updated - +- Weather module - forecast now show TODAY and TOMORROW instead of weekday, to make it easier to understand ### Deleted ### Fixed From 7462d61e169ac04a46175b2ddb9efaab4a84a8fe Mon Sep 17 00:00:00 2001 From: Erik Pettersson Date: Sun, 11 Oct 2020 21:35:42 +0200 Subject: [PATCH 12/39] Makes the module stay hidden without a lock. When this module is hidden from another module, it un-hides itself when it updates itself. With this change it stays hidden, as it should. :) --- modules/default/currentweather/currentweather.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 0a43b23e..376732a9 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -495,11 +495,12 @@ Module.register("currentweather", { this.sunriseSunsetTime = timeString; this.sunriseSunsetIcon = sunrise < now && sunset > now ? "wi-sunset" : "wi-sunrise"; - - this.show(this.config.animationSpeed, { lockString: this.identifier }); - this.loaded = true; - this.updateDom(this.config.animationSpeed); - this.sendNotification("CURRENTWEATHER_DATA", { data: data }); + if (!this.hidden) { + this.show(this.config.animationSpeed, { lockString: this.identifier }); + this.loaded = true; + this.updateDom(this.config.animationSpeed); + this.sendNotification("CURRENTWEATHER_DATA", { data: data }); + } }, /* scheduleUpdate() From ecd9828afc11bc09c64164724e2746f57e371fea Mon Sep 17 00:00:00 2001 From: Erik Pettersson Date: Sun, 11 Oct 2020 21:37:00 +0200 Subject: [PATCH 13/39] Makes the module stay hidden without a lock. When this module is hidden from another module, it un-hides itself when it updates itself. With this change it stays hidden, as it should. :) --- modules/default/weatherforecast/weatherforecast.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 4ecc18aa..f8550022 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -408,9 +408,11 @@ Module.register("weatherforecast", { } //Log.log(this.forecast); - this.show(this.config.animationSpeed, { lockString: this.identifier }); - this.loaded = true; - this.updateDom(this.config.animationSpeed); + if (!this.hidden) { + this.show(this.config.animationSpeed, { lockString: this.identifier }); + this.loaded = true; + this.updateDom(this.config.animationSpeed); + } }, /* scheduleUpdate() From 644aa26b7571cfce7f0afa7d647482d94f1a0c5a Mon Sep 17 00:00:00 2001 From: Erik Pettersson Date: Sun, 11 Oct 2020 21:41:59 +0200 Subject: [PATCH 14/39] Update CHANGELOG.md Added the "currentwather" and "watherforcast" update show fixes information. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb61bd24..5777142d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ _This release is scheduled to be released on 2021-01-01._ ### Fixed +- Fixed the "un-hide on update" problem with "currentwather" and "watherforcast" modules. - JSON Parse translation files with comments crashing UI. (#2149) - Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) - Wrong node-ical version installed (package.json) requested version. (#2153) From a3bad8aec41e4d7f09588b1bf5fcea39f8b92359 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 11 Oct 2020 22:39:42 -0500 Subject: [PATCH 15/39] fix subsequent calendar fetcher timing --- modules/default/calendar/calendar.js | 15 +++++++++++---- modules/default/calendar/node_helper.js | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index af804139..5a8c2628 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -29,7 +29,7 @@ Module.register("calendar", { timeFormat: "relative", dateFormat: "MMM Do", dateEndFormat: "LT", - fullDayEventDateFormat: "MMM Do", + fullDayEventDateFormat: "MMM Do HH:mm", showEnd: false, getRelative: 6, fadePoint: 0.25, // Start on 1/4th of the list. @@ -41,7 +41,7 @@ Module.register("calendar", { calendars: [ { symbol: "calendar", - url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics" + url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics1" } ], titleReplace: { @@ -58,6 +58,8 @@ Module.register("calendar", { nextDaysRelative: false }, + requiresVersion: "2.1.0", + // Define required scripts. getStyles: function () { return ["calendar.css", "font-awesome.css"]; @@ -114,12 +116,12 @@ Module.register("calendar", { this.addCalendar(calendar.url, calendar.auth, calendarConfig); - // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar + /* // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar // fetcher running on the server side. var self = this; setInterval(function () { self.addCalendar(calendar.url, calendar.auth, calendarConfig); - }, self.config.fetchInterval); + }, self.config.fetchInterval); */ } this.calendarData = {}; @@ -541,6 +543,8 @@ Module.register("calendar", { * @param {object} calendarConfig The config of the specific calendar */ addCalendar: function (url, auth, calendarConfig) { + var self = this; + this.sendSocketNotification("ADD_CALENDAR", { id: this.identifier, url: url, @@ -554,6 +558,9 @@ Module.register("calendar", { auth: auth, broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents }); + setTimeout(() => { + self.addCalendar(url, auth, calendarConfig); + }, self.config.fetchInterval); }, /** diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 862755a0..1c88b9af 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -70,7 +70,7 @@ module.exports = NodeHelper.create({ } else { Log.log("Use existing calendar fetcher for url: " + url); fetcher = self.fetchers[identifier + url]; - fetcher.broadcastEvents(); + //fetcher.broadcastEvents(); } fetcher.startFetch(); From e8f60d39de8ad8d9b44d63362698a6e8e2c9146f Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 11 Oct 2020 22:43:11 -0500 Subject: [PATCH 16/39] fix subsequent calendar fetcher timing --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08610111..c360e511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ _This release is scheduled to be released on 2021-01-01._ ### Fixed +- JSON Parse translation files with comments crashing UI. (#2149) +- Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) +- Wrong node-ical version installed (package.json) requested version. (#2153) +- Fix calendar fetcher subsequent timing (#2160) + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. From 3b76ca4f9ba6527aa31c5672d2aa324541506246 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:09:42 +0200 Subject: [PATCH 17/39] Update forecast.njk --- modules/default/weather/forecast.njk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index 98569e23..ae752637 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -19,15 +19,15 @@ {% endif %} - {{ f.maxTemperature | roundValue | unit("temperature") }} + {{ f.maxTemperature | roundValue | unit("temperature") }} - {{ f.minTemperature | roundValue | unit("temperature") }} + {{ f.minTemperature | roundValue | unit("temperature") }} {% if config.showPrecipitationAmount %} - - {{ f.precipitation | unit("precip") }} - + + {{ f.precipitation | unit("precip") }} + {% endif %} {% set currentStep = currentStep + 1 %} From d11696015d5ed200f6ece6b03c305a292f367398 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:10:51 +0200 Subject: [PATCH 18/39] Update forecast.njk --- modules/default/weather/forecast.njk | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index ae752637..85ed0fef 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -10,25 +10,25 @@ {% set forecast = forecast.slice(0, numSteps) %} {% for f in forecast %} - {% if (currentStep == 0) %} - {{ "TODAY" | translate }} - {% elif (currentStep == 1) %} - {{ "TOMORROW" | translate }} - {% else %} - {{ f.date.format('ddd') }} - {% endif %} - - - {{ f.maxTemperature | roundValue | unit("temperature") }} - - - {{ f.minTemperature | roundValue | unit("temperature") }} - - {% if config.showPrecipitationAmount %} - - {{ f.precipitation | unit("precip") }} + {% if (currentStep == 0) %} + {{ "TODAY" | translate }} + {% elif (currentStep == 1) %} + {{ "TOMORROW" | translate }} + {% else %} + {{ f.date.format('ddd') }} + {% endif %} + + + {{ f.maxTemperature | roundValue | unit("temperature") }} - {% endif %} + + {{ f.minTemperature | roundValue | unit("temperature") }} + + {% if config.showPrecipitationAmount %} + + {{ f.precipitation | unit("precip") }} + + {% endif %} {% set currentStep = currentStep + 1 %} {% endfor %} From 4a7cb88a3e8f55131ad1c78c7d58781dc8f813f8 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 12 Oct 2020 09:01:50 -0500 Subject: [PATCH 19/39] typo, remove dead code, comments, fix recurring refresh, let fetcher handle it --- modules/default/calendar/calendar.js | 25 +++++++++------------ modules/default/calendar/calendarfetcher.js | 7 ++---- modules/default/calendar/node_helper.js | 1 - 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 5a8c2628..b2737586 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -29,7 +29,7 @@ Module.register("calendar", { timeFormat: "relative", dateFormat: "MMM Do", dateEndFormat: "LT", - fullDayEventDateFormat: "MMM Do HH:mm", + fullDayEventDateFormat: "MMM Do", showEnd: false, getRelative: 6, fadePoint: 0.25, // Start on 1/4th of the list. @@ -41,7 +41,7 @@ Module.register("calendar", { calendars: [ { symbol: "calendar", - url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics1" + url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics" } ], titleReplace: { @@ -85,6 +85,12 @@ Module.register("calendar", { // Set locale. moment.updateLocale(config.language, this.getLocaleSpecification(config.timeFormat)); + // clear data holder before start + this.calendarData = {}; + + // indicate no data available yet + this.loaded = false; + for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; calendar.url = calendar.url.replace("webcal://", "http://"); @@ -114,18 +120,10 @@ Module.register("calendar", { }; } + // tell helper to start a fetcher for this calendar + // fetcher till cycle this.addCalendar(calendar.url, calendar.auth, calendarConfig); - - /* // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar - // fetcher running on the server side. - var self = this; - setInterval(function () { - self.addCalendar(calendar.url, calendar.auth, calendarConfig); - }, self.config.fetchInterval); */ } - - this.calendarData = {}; - this.loaded = false; }, // Override socket notification handler. @@ -558,9 +556,6 @@ Module.register("calendar", { auth: auth, broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents }); - setTimeout(() => { - self.addCalendar(url, auth, calendarConfig); - }, self.config.fetchInterval); }, /** diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 964cb955..8ea982f8 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -340,11 +340,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } }); - newEvents.sort(function (a, b) { - return a.startDate - b.startDate; - }); - - events = newEvents.slice(0, maximumEntries); + // send all our events to upper to merge, sort and reduce for display + events = newEvents; self.broadcastEvents(); scheduleTimer(); diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 1c88b9af..06fa28ec 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -70,7 +70,6 @@ module.exports = NodeHelper.create({ } else { Log.log("Use existing calendar fetcher for url: " + url); fetcher = self.fetchers[identifier + url]; - //fetcher.broadcastEvents(); } fetcher.startFetch(); From 485f662d7553c1bc8dcd086e3c1db1d4e869b255 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 12 Oct 2020 10:12:47 -0500 Subject: [PATCH 20/39] revert fetcher filtering results --- modules/default/calendar/calendarfetcher.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index ca0d6cd9..f153f7c0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -395,8 +395,11 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } }); - // send all our events to upper to merge, sort and reduce for display - events = newEvents; + newEvents.sort(function (a, b) { + return a.startDate - b.startDate; + }); + + events = newEvents.slice(0, maximumEntries); self.broadcastEvents(); scheduleTimer(); From 43b6c712052d5e081028f1cd0efc316ba643b750 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 13 Oct 2020 16:14:52 +0200 Subject: [PATCH 21/39] Revert "Fixes the un-hide problem with currentwether and weatherforcast modules." --- CHANGELOG.md | 1 - modules/default/currentweather/currentweather.js | 11 +++++------ modules/default/weatherforecast/weatherforecast.js | 8 +++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efd7e19d..c360e511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ _This release is scheduled to be released on 2021-01-01._ ### Fixed -- Fixed the "un-hide on update" problem with "currentwather" and "watherforcast" modules. - JSON Parse translation files with comments crashing UI. (#2149) - Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) - Wrong node-ical version installed (package.json) requested version. (#2153) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 376732a9..0a43b23e 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -495,12 +495,11 @@ Module.register("currentweather", { this.sunriseSunsetTime = timeString; this.sunriseSunsetIcon = sunrise < now && sunset > now ? "wi-sunset" : "wi-sunrise"; - if (!this.hidden) { - this.show(this.config.animationSpeed, { lockString: this.identifier }); - this.loaded = true; - this.updateDom(this.config.animationSpeed); - this.sendNotification("CURRENTWEATHER_DATA", { data: data }); - } + + this.show(this.config.animationSpeed, { lockString: this.identifier }); + this.loaded = true; + this.updateDom(this.config.animationSpeed); + this.sendNotification("CURRENTWEATHER_DATA", { data: data }); }, /* scheduleUpdate() diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index f8550022..4ecc18aa 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -408,11 +408,9 @@ Module.register("weatherforecast", { } //Log.log(this.forecast); - if (!this.hidden) { - this.show(this.config.animationSpeed, { lockString: this.identifier }); - this.loaded = true; - this.updateDom(this.config.animationSpeed); - } + this.show(this.config.animationSpeed, { lockString: this.identifier }); + this.loaded = true; + this.updateDom(this.config.animationSpeed); }, /* scheduleUpdate() From 3c84002abda8cad6a1650a1950e54ed0ce2dae90 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 15 Oct 2020 09:20:44 +0200 Subject: [PATCH 22/39] Fix linter issues. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce7a75a4..7e5fedea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ _This release is scheduled to be released on 2021-01-01._ ### Added ### Updated + - Weather module - forecast now show TODAY and TOMORROW instead of weekday, to make it easier to understand + ### Deleted ### Fixed From 02148f68e5c7280fd4244b35f65c55d9cdd73a5a Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 15 Oct 2020 09:26:56 +0200 Subject: [PATCH 23/39] Rename greek translation. (#2155) --- CHANGELOG.md | 1 + translations/{gr.json => el.json} | 0 translations/translations.js | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) rename translations/{gr.json => el.json} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c360e511..82fc88fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ _This release is scheduled to be released on 2021-01-01._ - Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) - Wrong node-ical version installed (package.json) requested version. (#2153) - Fix calendar fetcher subsequent timing (#2160) +- Rename Greek translation to correct ISO 639-1 alpha-2 code (gr > el). (#2155) ## [2.13.0] - 2020-10-01 diff --git a/translations/gr.json b/translations/el.json similarity index 100% rename from translations/gr.json rename to translations/el.json diff --git a/translations/translations.js b/translations/translations.js index 7d0fcfa0..b972b9a8 100644 --- a/translations/translations.js +++ b/translations/translations.js @@ -25,7 +25,7 @@ var translations = { "zh-tw": "translations/zh-tw.json", // Traditional Chinese ja: "translations/ja.json", // Japanese pl: "translations/pl.json", // Polish - gr: "translations/gr.json", // Greek + el: "translations/el.json", // Greek da: "translations/da.json", // Danish tr: "translations/tr.json", // Turkish ru: "translations/ru.json", // Russian From 5781c258e0d2fc394be84795bde21e3bb99caa2a Mon Sep 17 00:00:00 2001 From: Szymon Bluma Date: Fri, 16 Oct 2020 12:19:48 +0200 Subject: [PATCH 24/39] A space after icon of sunrise and sunset --- CHANGELOG.md | 1 + modules/default/clock/clock.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fc88fa..5132d110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ _This release is scheduled to be released on 2021-01-01._ - Wrong node-ical version installed (package.json) requested version. (#2153) - Fix calendar fetcher subsequent timing (#2160) - Rename Greek translation to correct ISO 639-1 alpha-2 code (gr > el). (#2155) +- Add a space after icons of sunrise and sunset (#2169) ## [2.13.0] - 2020-10-01 diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index 1c7109b6..6e3d7090 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -187,10 +187,10 @@ Module.register("clock", { '"> ' + untilNextEventString + "" + - '' + + ' ' + formatTime(this.config, sunTimes.sunrise) + "" + - '' + + ' ' + formatTime(this.config, sunTimes.sunset) + ""; } From e09fec56e257c988adc099d5f54c59fd2a2ff6b7 Mon Sep 17 00:00:00 2001 From: flopp999 <21694965+flopp999@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:26:39 +0200 Subject: [PATCH 25/39] Update weather_spec.js try to change the default to Today and Tomorrow --- tests/e2e/modules/weather_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/modules/weather_spec.js b/tests/e2e/modules/weather_spec.js index d87a44cd..2d9f3f01 100644 --- a/tests/e2e/modules/weather_spec.js +++ b/tests/e2e/modules/weather_spec.js @@ -186,7 +186,7 @@ describe("Weather module", function () { const weather = generateWeatherForecast(); await setup({ template, data: weather }); - const days = ["Fri", "Sat", "Sun", "Mon", "Tue"]; + const days = ["Today", "Tomorrow", "Sun", "Mon", "Tue"]; for (const [index, day] of days.entries()) { await app.client.waitUntilTextExists(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day, 10000); From e83b4d7d421682726ec4eb206e62f5b81fb86e8b Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 26 Oct 2020 09:55:35 -0500 Subject: [PATCH 26/39] fix calendar when event has no DTEND record --- CHANGELOG.md | 1 + modules/default/calendar/calendarfetcher.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5132d110..d6958514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ _This release is scheduled to be released on 2021-01-01._ - Fix calendar fetcher subsequent timing (#2160) - Rename Greek translation to correct ISO 639-1 alpha-2 code (gr > el). (#2155) - Add a space after icons of sunrise and sunset (#2169) +- Fix calendar when no DTEND record found in event, startDate overlay when endDate set (#2177) ## [2.13.0] - 2020-10-01 diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index f153f7c0..e7406584 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -117,7 +117,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn endDate = startDate.clone().add(moment.duration(event.duration)); } else { if (!isFacebookBirthday) { - endDate = startDate; + // make copy of start date, separate storage area + endDate = moment(startDate.format("x"), "x"); } else { endDate = moment(startDate).add(1, "days"); } From b624aeec454ee87b9c80572af8313ad279fc27a7 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 26 Oct 2020 12:41:03 -0500 Subject: [PATCH 27/39] fix the fullDayEvent checker function --- modules/default/calendar/calendarfetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index e7406584..f228481a 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -440,7 +440,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn * @returns {boolean} True if the event is a fullday event, false otherwise */ const isFullDayEvent = function (event) { - if (event.start.length === 8 || event.start.dateOnly) { + if (event.start.length === 8 || event.start.dateOnly || event.datetype == "date") { return true; } From 8a1d46deb4e600ea2fb68d29bbcadda82b6df6fc Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 26 Oct 2020 12:52:32 -0500 Subject: [PATCH 28/39] fix fullday event compare operator --- modules/default/calendar/calendarfetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index f228481a..f29dc9e0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -440,7 +440,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn * @returns {boolean} True if the event is a fullday event, false otherwise */ const isFullDayEvent = function (event) { - if (event.start.length === 8 || event.start.dateOnly || event.datetype == "date") { + if (event.start.length === 8 || event.start.dateOnly || event.datetype === "date") { return true; } From a7352758649608c393cb4b7915668ecdaa3a0c37 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 09:31:05 -0500 Subject: [PATCH 29/39] fix full day recurring events east of UTC for RRULE/Luxon confusion, also update windows zones to include old offset based strings (UTC+05:00) US Eastern and Canada --- modules/default/calendar/calendarfetcher.js | 148 +++++++++++++------- modules/default/calendar/windowsZones.json | 100 ++++++++++++- 2 files changed, 196 insertions(+), 52 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index f29dc9e0..1d0e24e0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -32,6 +32,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let reloadTimer = null; let events = []; + let debug = false; let fetchFailedCallback = function () {}; let eventsReceivedCallback = function () {}; @@ -215,7 +216,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } const dates = rule.between(pastLocal, futureLocal, true, limitFunction); - // console.log("title="+event.summary.val+" dates="+JSON.stringify(dates)) + if (debug) console.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, @@ -243,54 +244,25 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let curEvent = event; let showRecurrence = true; + // for full day events, the time might be off from RRULE/Luxon problem + if (isFullDayEvent(event)) { + if (debug) console.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); + // reduce the time by the offset + if (debug) console.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); + } + } startDate = moment(date); - // console.log("now timezone="+ moment.tz.guess()); - // whether we need to adjust for RRULE returning the wrong date, with the right time (forward of URC timezones) - let adjustDays = 0; - // if a timezone was specified - if (!event.start.tz) { - event.start.tz = moment.tz.guess(); - } - // console.log("tz="+event.start.tz) - if (event.start.tz) { - // if this is a windows timezone - if (event.start.tz.indexOf(" ") > 0) { - // use the lookup table to get theIANA name as moment and date don't know MS timezones - let tz = getIanaTZFromMS(event.start.tz); - // watch out for unregistered windows timezone names - // if we had a successfule lookup - if (tz) { - // change the timezone to the IANA name - event.start.tz = getIanaTZFromMS(event.start.tz); - // console.log("corrected timezone="+event.start.tz) - } - } - // get the start time in that timezone - let mms = moment.tz(moment(event.start), event.start.tz).utcOffset(); - // console.log("ms offset="+mms) - // get the specified date in that timezone - let mm = moment.tz(moment(date), event.start.tz); - let mmo = mm.utcOffset(); - // console.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) { - let h = parseInt(mm.format("H")); - // check if the event time is less than the offset - if (h > 0 && h < mmo / 60) { - // if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time) - // we need to fix that - adjustDays = 24; - // console.log("adjusting date") - } - if (mmo > mms) { - adjustDays += 1; - // console.log("adjust up 1 hour dst change") - } else if (mmo < mms) { - adjustDays -= 1; - //console.log("adjust down 1 hour dst change") - } - } - } + + let adjustDays = getCorrection(event, date); // For each date that we're checking, it's possible that there is a recurrence override for that one day. if (curEvent.recurrences !== undefined && curEvent.recurrences[dateKey] !== undefined) { @@ -380,12 +352,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn //console.log("end same as start") endDate = endDate.endOf("day"); } - + // get correction for date saving and dst change between now and then + let adjustDays = getCorrection(event, startDate.toDate()); // Every thing is good. Add it to the list. newEvents.push({ title: title, - startDate: startDate.format("x"), - endDate: endDate.format("x"), + startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"), + endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"), fullDayEvent: fullDayEvent, class: event.class, location: location, @@ -407,6 +380,79 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn }); }; + /* + * + * get the time correction, either dst/std or full day in cases where utc time is day before plus offset + * + */ + const getCorrection = function (event, date) { + let adjustHours = 0; + // if a timezone was specified + if (!event.start.tz) { + if (debug) console.log(" if no tz, guess based on now"); + event.start.tz = moment.tz.guess(); + } + if (debug) console.log("initial tz=" + event.start.tz); + + // if there is a start date specified + if (event.start.tz) { + // if this is a windows timezone + if (event.start.tz.includes(" ")) { + // use the lookup table to get theIANA name as moment and date don't know MS timezones + let tz = getIanaTZFromMS(event.start.tz); + // watch out for unregistered windows timezone names + // if we had a successfule lookup + if (tz) { + // change the timezone to the IANA name + event.start.tz = tz; + // if(debug) console.log("corrected timezone="+event.start.tz) + } + } + if (debug) console.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); + } + + // get the start time in that timezone + if (debug) console.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) console.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()); + let mmo = mm.utcOffset(); + if (debug) console.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"); + 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 (mmo > mms) { + adjustHours += 1; + if (debug) console.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) console.log("adjustHours=" + adjustHours); + return adjustHours; + }; + /** * * lookup iana tz from windows diff --git a/modules/default/calendar/windowsZones.json b/modules/default/calendar/windowsZones.json index 2e6bd6b3..cad82bb9 100644 --- a/modules/default/calendar/windowsZones.json +++ b/modules/default/calendar/windowsZones.json @@ -135,5 +135,103 @@ "UTC+13": { "iana": ["Etc/GMT-13"] }, "Tonga Standard Time": { "iana": ["Pacific/Tongatapu"] }, "Samoa Standard Time": { "iana": ["Pacific/Apia"] }, - "Line Islands Standard Time": { "iana": ["Pacific/Kiritimati"] } + "Line Islands Standard Time": { "iana": ["Pacific/Kiritimati"] }, + "(UTC-12:00) International Date Line West": { "iana": ["Etc/GMT+12"] }, + "(UTC-11:00) Midway Island, Samoa": { "iana": ["Pacific/Apia"] }, + "(UTC-10:00) Hawaii": { "iana": ["Pacific/Honolulu"] }, + "(UTC-09:00) Alaska": { "iana": ["America/Anchorage"] }, + "(UTC-08:00) Pacific Time (US & Canada); Tijuana": { "iana": ["America/Los_Angeles"] }, + "(UTC-08:00) Pacific Time (US and Canada); Tijuana": { "iana": ["America/Los_Angeles"] }, + "(UTC-07:00) Mountain Time (US & Canada)": { "iana": ["America/Denver"] }, + "(UTC-07:00) Mountain Time (US and Canada)": { "iana": ["America/Denver"] }, + "(UTC-07:00) Chihuahua, La Paz, Mazatlan": { "iana": [null] }, + "(UTC-07:00) Arizona": { "iana": ["America/Phoenix"] }, + "(UTC-06:00) Central Time (US & Canada)": { "iana": ["America/Chicago"] }, + "(UTC-06:00) Central Time (US and Canada)": { "iana": ["America/Chicago"] }, + "(UTC-06:00) Saskatchewan": { "iana": ["America/Regina"] }, + "(UTC-06:00) Guadalajara, Mexico City, Monterrey": { "iana": [null] }, + "(UTC-06:00) Central America": { "iana": ["America/Guatemala"] }, + "(UTC-05:00) Eastern Time (US & Canada)": { "iana": ["America/New_York"] }, + "(UTC-05:00) Eastern Time (US and Canada)": { "iana": ["America/New_York"] }, + "(UTC-05:00) Indiana (East)": { "iana": ["America/Indianapolis"] }, + "(UTC-05:00) Bogota, Lima, Quito": { "iana": ["America/Bogota"] }, + "(UTC-04:00) Atlantic Time (Canada)": { "iana": ["America/Halifax"] }, + "(UTC-04:00) Georgetown, La Paz, San Juan": { "iana": ["America/La_Paz"] }, + "(UTC-04:00) Santiago": { "iana": ["America/Santiago"] }, + "(UTC-03:30) Newfoundland": { "iana": [null] }, + "(UTC-03:00) Brasilia": { "iana": ["America/Sao_Paulo"] }, + "(UTC-03:00) Georgetown": { "iana": ["America/Cayenne"] }, + "(UTC-03:00) Greenland": { "iana": ["America/Godthab"] }, + "(UTC-02:00) Mid-Atlantic": { "iana": [null] }, + "(UTC-01:00) Azores": { "iana": ["Atlantic/Azores"] }, + "(UTC-01:00) Cape Verde Islands": { "iana": ["Atlantic/Cape_Verde"] }, + "(UTC) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London": { "iana": [null] }, + "(UTC) Monrovia, Reykjavik": { "iana": ["Atlantic/Reykjavik"] }, + "(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague": { "iana": ["Europe/Budapest"] }, + "(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb": { "iana": ["Europe/Warsaw"] }, + "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris": { "iana": ["Europe/Paris"] }, + "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna": { "iana": ["Europe/Berlin"] }, + "(UTC+01:00) West Central Africa": { "iana": ["Africa/Lagos"] }, + "(UTC+02:00) Minsk": { "iana": ["Europe/Chisinau"] }, + "(UTC+02:00) Cairo": { "iana": ["Africa/Cairo"] }, + "(UTC+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius": { "iana": ["Europe/Kiev"] }, + "(UTC+02:00) Athens, Bucharest, Istanbul": { "iana": ["Europe/Bucharest"] }, + "(UTC+02:00) Jerusalem": { "iana": ["Asia/Jerusalem"] }, + "(UTC+02:00) Harare, Pretoria": { "iana": ["Africa/Johannesburg"] }, + "(UTC+03:00) Moscow, St. Petersburg, Volgograd": { "iana": ["Europe/Moscow"] }, + "(UTC+03:00) Kuwait, Riyadh": { "iana": ["Asia/Riyadh"] }, + "(UTC+03:00) Nairobi": { "iana": ["Africa/Nairobi"] }, + "(UTC+03:00) Baghdad": { "iana": ["Asia/Baghdad"] }, + "(UTC+03:30) Tehran": { "iana": ["Asia/Tehran"] }, + "(UTC+04:00) Abu Dhabi, Muscat": { "iana": ["Asia/Dubai"] }, + "(UTC+04:00) Baku, Tbilisi, Yerevan": { "iana": ["Asia/Yerevan"] }, + "(UTC+04:30) Kabul": { "iana": [null] }, + "(UTC+05:00) Ekaterinburg": { "iana": ["Asia/Yekaterinburg"] }, + "(UTC+05:00) Tashkent": { "iana": ["Asia/Tashkent"] }, + "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi": { "iana": ["Asia/Calcutta"] }, + "(UTC+05:45) Kathmandu": { "iana": ["Asia/Katmandu"] }, + "(UTC+06:00) Astana, Dhaka": { "iana": ["Asia/Almaty"] }, + "(UTC+06:00) Sri Jayawardenepura": { "iana": ["Asia/Colombo"] }, + "(UTC+06:00) Almaty, Novosibirsk": { "iana": ["Asia/Novosibirsk"] }, + "(UTC+06:30) Yangon (Rangoon)": { "iana": ["Asia/Rangoon"] }, + "(UTC+07:00) Bangkok, Hanoi, Jakarta": { "iana": ["Asia/Bangkok"] }, + "(UTC+07:00) Krasnoyarsk": { "iana": ["Asia/Krasnoyarsk"] }, + "(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi": { "iana": ["Asia/Shanghai"] }, + "(UTC+08:00) Kuala Lumpur, Singapore": { "iana": ["Asia/Singapore"] }, + "(UTC+08:00) Taipei": { "iana": ["Asia/Taipei"] }, + "(UTC+08:00) Perth": { "iana": ["Australia/Perth"] }, + "(UTC+08:00) Irkutsk, Ulaanbaatar": { "iana": ["Asia/Irkutsk"] }, + "(UTC+09:00) Seoul": { "iana": ["Asia/Seoul"] }, + "(UTC+09:00) Osaka, Sapporo, Tokyo": { "iana": ["Asia/Tokyo"] }, + "(UTC+09:00) Yakutsk": { "iana": ["Asia/Yakutsk"] }, + "(UTC+09:30) Darwin": { "iana": ["Australia/Darwin"] }, + "(UTC+09:30) Adelaide": { "iana": ["Australia/Adelaide"] }, + "(UTC+10:00) Canberra, Melbourne, Sydney": { "iana": ["Australia/Sydney"] }, + "(GMT+10:00) Canberra, Melbourne, Sydney": { "iana": ["Australia/Sydney"] }, + "(UTC+10:00) Brisbane": { "iana": ["Australia/Brisbane"] }, + "(UTC+10:00) Hobart": { "iana": ["Australia/Hobart"] }, + "(UTC+10:00) Vladivostok": { "iana": ["Asia/Vladivostok"] }, + "(UTC+10:00) Guam, Port Moresby": { "iana": ["Pacific/Port_Moresby"] }, + "(UTC+11:00) Magadan, Solomon Islands, New Caledonia": { "iana": ["Pacific/Guadalcanal"] }, + "(UTC+12:00) Fiji, Kamchatka, Marshall Is.": { "iana": [null] }, + "(UTC+12:00) Auckland, Wellington": { "iana": ["Pacific/Auckland"] }, + "(UTC+13:00) Nuku'alofa": { "iana": ["Pacific/Tongatapu"] }, + "(UTC-03:00) Buenos Aires": { "iana": ["America/Buenos_Aires"] }, + "(UTC+02:00) Beirut": { "iana": ["Asia/Beirut"] }, + "(UTC+02:00) Amman": { "iana": ["Asia/Amman"] }, + "(UTC-06:00) Guadalajara, Mexico City, Monterrey - New": { "iana": ["America/Mexico_City"] }, + "(UTC-07:00) Chihuahua, La Paz, Mazatlan - New": { "iana": ["America/Chihuahua"] }, + "(UTC-08:00) Tijuana, Baja California": { "iana": ["America/Tijuana"] }, + "(UTC+02:00) Windhoek": { "iana": ["Africa/Windhoek"] }, + "(UTC+03:00) Tbilisi": { "iana": ["Asia/Tbilisi"] }, + "(UTC-04:00) Manaus": { "iana": ["America/Cuiaba"] }, + "(UTC-03:00) Montevideo": { "iana": ["America/Montevideo"] }, + "(UTC+04:00) Yerevan": { "iana": [null] }, + "(UTC-04:30) Caracas": { "iana": ["America/Caracas"] }, + "(UTC) Casablanca": { "iana": ["Africa/Casablanca"] }, + "(UTC+05:00) Islamabad, Karachi": { "iana": ["Asia/Karachi"] }, + "(UTC+04:00) Port Louis": { "iana": ["Indian/Mauritius"] }, + "(UTC) Coordinated Universal Time": { "iana": ["Etc/GMT"] }, + "(UTC-04:00) Asuncion": { "iana": ["America/Asuncion"] }, + "(UTC+12:00) Petropavlovsk-Kamchatsky": { "iana": [null] } } From 74b0c3ea57dafa454300864da430167cc657d865 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 09:32:38 -0500 Subject: [PATCH 30/39] update node-ical dependency version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 195099ec..c3ff7aa3 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "iconv-lite": "^0.6.2", "module-alias": "^2.2.2", "moment": "^2.28.0", - "node-ical": "^0.12.1", + "node-ical": "^0.12.3", "request": "^2.88.2", "rrule": "^2.6.6", "rrule-alt": "^2.2.8", From 1e0fc7eb0d5c4bcff2b6269d5e17cc273b443786 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 09:38:31 -0500 Subject: [PATCH 31/39] add package-lock for test --- package-lock.json | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3eb0550e..5ac7aa7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5723,24 +5723,20 @@ "dev": true }, "node-ical": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/node-ical/-/node-ical-0.12.1.tgz", - "integrity": "sha512-1YlvRyfOs0fUr8KWtgj4r/4VMI0tuBLfVSyrmDk00jLuUkXouiSU0PptEGdJs3U3pibF8ZThU6rVVS/jkcXJBQ==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/node-ical/-/node-ical-0.12.3.tgz", + "integrity": "sha512-MCr71z5mUcF7LuC3iIPKMKcaQ4Mr5cft0Uh00BBnkOrsm6vdS2xTUOKy1vhaYZ1V711LJmSAwQakxBXxLlHY3g==", "requires": { "moment-timezone": "^0.5.31", "request": "^2.88.2", - "rrule": "2.6.4", - "uuid": "^3.3.2" + "rrule": "2.6.6", + "uuid": "^8.3.1" }, "dependencies": { - "rrule": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/rrule/-/rrule-2.6.4.tgz", - "integrity": "sha512-sLdnh4lmjUqq8liFiOUXD5kWp/FcnbDLPwq5YAc/RrN6120XOPb86Ae5zxF7ttBVq8O3LxjjORMEit1baluahA==", - "requires": { - "luxon": "^1.21.3", - "tslib": "^1.10.0" - } + "uuid": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" } } }, From 8466ff0c1a1693126a877f4700d10cc1dbbdbbdd Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 09:42:00 -0500 Subject: [PATCH 32/39] change debug logging from console. to Log. --- modules/default/calendar/calendarfetcher.js | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 1d0e24e0..c12dfb1d 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -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; }; From b73cfd8a607f7659dc6f5582bf51bac2054eeaf9 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 16:42:20 +0100 Subject: [PATCH 33/39] fix time adjustment routine --- modules/default/calendar/calendarfetcher.js | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) 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; From 82c742f96443297cd83bd7e47782b645d6f8dde3 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 16:55:53 +0100 Subject: [PATCH 34/39] fix prettier problems, was run on commit before --- modules/default/calendar/calendarfetcher.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index b7f89b1d..7adbb2d0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -409,18 +409,18 @@ 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 + 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*/; - mms=mmo = event.start.tz.match(regex).toString(); + mmo = event.start.tz.match(regex).toString(); + mms = mmo; if (debug) Log.log("ical offset=" + mmo); mm = moment.tz(moment(date)); - mm.utcOffset(mmo) - } - else { + mm = 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(); @@ -429,7 +429,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn if (debug) Log.log("start date =" + moment.tz(moment(event.start), event.start.tz).toDate()); // 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()); mmo = mm.utcOffset(); } @@ -440,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; From 844a59d880391c4650567b19ef3b678937b92933 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Wed, 28 Oct 2020 13:10:24 -0500 Subject: [PATCH 35/39] one more offset only test --- modules/default/calendar/calendarfetcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 7adbb2d0..5d87d7c8 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -417,8 +417,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn const regex = /[+|-]\d*:\d*/; mmo = event.start.tz.match(regex).toString(); mms = mmo; - if (debug) Log.log("ical offset=" + mmo); - mm = moment.tz(moment(date)); + if (debug) Log.log("ical offset=" + mmo + " date=" + date); + mm = moment(date); mm = mm.utcOffset(mmo); } else { // get the start time in that timezone From 5d2f706c321cdadf9faec4d91cb212ee5e98d19d Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 1 Nov 2020 09:05:33 -0600 Subject: [PATCH 36/39] fix time offset calcs for any timezone --- modules/default/calendar/calendarfetcher.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 5d87d7c8..5161937c 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -300,8 +300,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn addedEvents++; newEvents.push({ title: recurrenceTitle, - startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"), - endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"), + startDate: (adjustDays ? (adjustDays > 0 ? startDate.add(adjustDays, "hours") : startDate.subtract(Math.abs(adjustDays), "hours")) : startDate).format("x"), + endDate: (adjustDays ? (adjustDays > 0 ? endDate.add(adjustDays, "hours") : endDate.subtract(Math.abs(adjustDays), "hours")) : endDate).format("x"), fullDayEvent: isFullDayEvent(event), recurringEvent: true, class: event.class, @@ -357,8 +357,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn // Every thing is good. Add it to the list. newEvents.push({ title: title, - startDate: (adjustDays ? startDate.subtract(adjustDays, "hours") : startDate).format("x"), - endDate: (adjustDays ? endDate.subtract(adjustDays, "hours") : endDate).format("x"), + startDate: (adjustDays ? (adjustDays > 0 ? startDate.add(adjustDays, "hours") : startDate.subtract(Math.abs(adjustDays), "hours")) : startDate).format("x"), + endDate: (adjustDays ? (adjustDays > 0 ? endDate.add(adjustDays, "hours") : endDate.subtract(Math.abs(adjustDays), "hours")) : endDate).format("x"), fullDayEvent: fullDayEvent, class: event.class, location: location, @@ -435,7 +435,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } 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) { + if (mmo !== mms) { // big offset if (debug) Log.log("offset"); let h = parseInt(mm.format("H")); @@ -446,10 +446,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn adjustHours = 24; // if(debug) Log.log("adjusting date") } - if (mmo > mms) { + if (Math.abs(mmo) > Math.abs(mms)) { adjustHours += 1; if (debug) Log.log("adjust up 1 hour dst change"); - } else if (mmo < mms) { + } else if (Math.abs(mmo) < Math.abs(mms)) { adjustHours -= 1; if (debug) Log.log("adjust down 1 hour dst change"); } From 5ac20d65ac7b9dcd3e9a91c6ed3ff84d84b5f235 Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 6 Nov 2020 11:47:09 +0100 Subject: [PATCH 37/39] Add new log level "debug" for such a purpose --- CHANGELOG.md | 4 +++- config/config.js.sample | 2 +- js/logger.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b56b1fc6..b6d2fa6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ _This release is scheduled to be released on 2021-01-01._ ### Added +- Added new log level "debug" to the logger. + ### Updated - Weather module - forecast now show TODAY and TOMORROW instead of weekday, to make it easier to understand @@ -229,7 +231,7 @@ Special thanks to @sdetweil for all his great contributions! - Option to show event location in calendar - Finnish translation for "Feels" and "Weeks" -- Russian translation for “Feels” +- Russian translation for "Feels" - Calendar module: added `nextDaysRelative` config option - Add `broadcastPastEvents` config option for calendars to include events from the past `maximumNumberOfDays` in event broadcasts - Added feature to broadcast news feed items `NEWS_FEED` and updated news items `NEWS_FEED_UPDATED` in default [newsfeed](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/newsfeed) module (when news is updated) with documented default and `config.js` options in [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md) diff --git a/config/config.js.sample b/config/config.js.sample index a0164198..55e84cb4 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -28,7 +28,7 @@ var config = { httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true language: "en", - logLevel: ["INFO", "LOG", "WARN", "ERROR"], + logLevel: ["DEBUG", "INFO", "LOG", "WARN", "ERROR"], timeFormat: 24, units: "metric", // serverOnly: true/false/"local" , diff --git a/js/logger.js b/js/logger.js index 0f33b473..e9e17c52 100644 --- a/js/logger.js +++ b/js/logger.js @@ -20,10 +20,11 @@ } })(this, function (config) { const logLevel = { + debug: Function.prototype.bind.call(console.debug, console), info: Function.prototype.bind.call(console.info, console), log: Function.prototype.bind.call(console.log, console), - error: Function.prototype.bind.call(console.error, console), warn: Function.prototype.bind.call(console.warn, console), + error: Function.prototype.bind.call(console.error, console), group: Function.prototype.bind.call(console.group, console), groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console), groupEnd: Function.prototype.bind.call(console.groupEnd, console), From 078438442a77647e80f579f2dc6e39e796446978 Mon Sep 17 00:00:00 2001 From: veeck Date: Fri, 6 Nov 2020 11:47:29 +0100 Subject: [PATCH 38/39] Cleanup some log levels --- modules/default/newsfeed/newsfeed.js | 16 ++++++++-------- .../weather/providers/ukmetofficedatahub.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 2ff02888..7fe2fb21 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -350,7 +350,7 @@ Module.register("newsfeed", { this.activeItem = 0; } this.resetDescrOrFullArticleAndTimer(); - Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); + Log.debug(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); this.updateDom(100); } else if (notification === "ARTICLE_PREVIOUS") { this.activeItem--; @@ -358,7 +358,7 @@ Module.register("newsfeed", { this.activeItem = this.newsItems.length - 1; } this.resetDescrOrFullArticleAndTimer(); - Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); + Log.debug(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); this.updateDom(100); } // if "more details" is received the first time: show article summary, on second time show full article @@ -367,8 +367,8 @@ Module.register("newsfeed", { if (this.config.showFullArticle === true) { this.scrollPosition += this.config.scrollLength; window.scrollTo(0, this.scrollPosition); - Log.info(this.name + " - scrolling down"); - Log.info(this.name + " - ARTICLE_MORE_DETAILS, scroll position: " + this.config.scrollLength); + Log.debug(this.name + " - scrolling down"); + Log.debug(this.name + " - ARTICLE_MORE_DETAILS, scroll position: " + this.config.scrollLength); } else { this.showFullArticle(); } @@ -376,12 +376,12 @@ Module.register("newsfeed", { if (this.config.showFullArticle === true) { this.scrollPosition -= this.config.scrollLength; window.scrollTo(0, this.scrollPosition); - Log.info(this.name + " - scrolling up"); - Log.info(this.name + " - ARTICLE_SCROLL_UP, scroll position: " + this.config.scrollLength); + Log.debug(this.name + " - scrolling up"); + Log.debug(this.name + " - ARTICLE_SCROLL_UP, scroll position: " + this.config.scrollLength); } } else if (notification === "ARTICLE_LESS_DETAILS") { this.resetDescrOrFullArticleAndTimer(); - Log.info(this.name + " - showing only article titles again"); + Log.debug(this.name + " - showing only article titles again"); this.updateDom(100); } else if (notification === "ARTICLE_TOGGLE_FULL") { if (this.config.showFullArticle) { @@ -411,7 +411,7 @@ Module.register("newsfeed", { } clearInterval(this.timer); this.timer = null; - Log.info(this.name + " - showing " + this.isShowingDescription ? "article description" : "full article"); + Log.debug(this.name + " - showing " + this.isShowingDescription ? "article description" : "full article"); this.updateDom(100); } }); diff --git a/modules/default/weather/providers/ukmetofficedatahub.js b/modules/default/weather/providers/ukmetofficedatahub.js index 9ed74684..505732d3 100644 --- a/modules/default/weather/providers/ukmetofficedatahub.js +++ b/modules/default/weather/providers/ukmetofficedatahub.js @@ -87,7 +87,7 @@ WeatherProvider.register("ukmetofficedatahub", { // Did not receive usable new data. // Maybe this needs a better check? Log.error("Possibly bad current/hourly data?"); - Log.info(data); + Log.error(data); return; } @@ -158,7 +158,7 @@ WeatherProvider.register("ukmetofficedatahub", { // Did not receive usable new data. // Maybe this needs a better check? Log.error("Possibly bad forecast data?"); - Log.info(data); + Log.error(data); return; } From 0a58767563917dd26f8d32411dd10064458c24ce Mon Sep 17 00:00:00 2001 From: rejas Date: Sat, 7 Nov 2020 11:59:01 +0100 Subject: [PATCH 39/39] Use Log.debug where applicable --- modules/default/calendar/calendarfetcher.js | 41 ++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 5161937c..3927897e 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -32,7 +32,6 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let reloadTimer = null; let events = []; - let debug = false; let fetchFailedCallback = function () {}; let eventsReceivedCallback = function () {}; @@ -216,7 +215,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } 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 // 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 +245,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) Log.log("fullday"); + Log.debug("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) Log.log("now offset is " + nowOffset); + Log.debug("now offset is " + nowOffset); // 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 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); @@ -389,10 +388,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn let adjustHours = 0; // if a timezone was specified 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(); } - if (debug) Log.log("initial tz=" + event.start.tz); + Log.debug("initial tz=" + event.start.tz); // if there is a start date specified if (event.start.tz) { @@ -405,10 +404,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn if (tz) { // change the timezone to the IANA name 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 mm = 0; // date with tz or offset let mms = 0; // utc offset of created with tz @@ -417,45 +416,45 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn const regex = /[+|-]\d*:\d*/; mmo = event.start.tz.match(regex).toString(); mms = mmo; - if (debug) Log.log("ical offset=" + mmo + " date=" + date); + Log.debug("ical offset=" + mmo + " date=" + date); mm = moment(date); mm = mm.utcOffset(mmo); } else { // 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(); - 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 mm = moment.tz(moment(date), event.start.tz); - if (debug) Log.log("mm=" + mm.toDate()); + Log.debug("mm=" + mm.toDate()); 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 (mmo !== mms) { // big offset - if (debug) Log.log("offset"); + Log.debug("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) Log.log("adjusting date") + Log.debug("adjusting date"); } if (Math.abs(mmo) > Math.abs(mms)) { 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)) { 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; };