From 04dae52a6ca82a0d754a788b5576e7d9c77ee290 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 4 Oct 2020 12:10:19 -0500 Subject: [PATCH 01/15] 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 964cb95563..bb3c4daa64 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 0000000000..2e6bd6b3fe --- /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 02/15] 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 0f4bc00a23..43b6529719 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 03/15] 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 01c38c4d38..f36422af52 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 5e4de9ac92..e52d99dd9f 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 04/15] 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 43b6529719..5dc500456a 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 05/15] 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 bb3c4daa64..f153f7c0bb 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 06/15] 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 b4cae7055b..8465927eb3 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 07/15] fix translation files with comments crashing UI --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae7055b..246effd89c 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 08/15] 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 b4cae7055b..a9ff0ca2e4 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 7462d61e169ac04a46175b2ddb9efaab4a84a8fe Mon Sep 17 00:00:00 2001 From: Erik Pettersson Date: Sun, 11 Oct 2020 21:35:42 +0200 Subject: [PATCH 09/15] 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 0a43b23e6b..376732a9b5 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 10/15] 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 4ecc18aae9..f855002271 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 11/15] 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 fb61bd2495..5777142d14 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 12/15] 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 af8041398b..5a8c2628de 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 862755a03c..1c88b9afb3 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 13/15] fix subsequent calendar fetcher timing --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08610111f6..c360e5113e 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 4a7cb88a3e8f55131ad1c78c7d58781dc8f813f8 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 12 Oct 2020 09:01:50 -0500 Subject: [PATCH 14/15] 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 5a8c2628de..b2737586f5 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 964cb95563..8ea982f824 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 1c88b9afb3..06fa28ec41 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 15/15] 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 ca0d6cd9e0..f153f7c0bb 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();