From e6c1fa7b255ba47d6038e3094fb3676058756099 Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Thu, 7 Mar 2024 10:32:53 -0800 Subject: [PATCH 1/4] Fix --- modules/default/calendar/calendarfetcherutils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/default/calendar/calendarfetcherutils.js b/modules/default/calendar/calendarfetcherutils.js index 4be451eb51..eec3540f29 100644 --- a/modules/default/calendar/calendarfetcherutils.js +++ b/modules/default/calendar/calendarfetcherutils.js @@ -311,6 +311,12 @@ const CalendarFetcherUtils = { arr[index] = new Date(date.valueOf() + oneDayInMs); } }); + // Adjusting the dates could push it beyond the 'until' date, so filter those out here. + if (rule.options.until !== null) { + dates = dates.filter((date) => { + return date.valueOf() <= rule.options.until.valueOf(); + }); + } } // The dates array from rrule can be confused by DST. If the event was created during DST and we From 551e6422090bc8012b8c1d3422b5bfb912813e20 Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Thu, 7 Mar 2024 10:43:29 -0800 Subject: [PATCH 2/4] unit test --- tests/configs/modules/calendar/rrule_until.js | 38 +++++++++++++++++++ tests/electron/modules/calendar_spec.js | 16 ++++++++ tests/mocks/rrule_until.ics | 24 ++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 tests/configs/modules/calendar/rrule_until.js create mode 100644 tests/mocks/rrule_until.ics diff --git a/tests/configs/modules/calendar/rrule_until.js b/tests/configs/modules/calendar/rrule_until.js new file mode 100644 index 0000000000..f6768482ef --- /dev/null +++ b/tests/configs/modules/calendar/rrule_until.js @@ -0,0 +1,38 @@ +/* MagicMirror² Test calendar exdate + * + * By jkriegshauser + * MIT Licensed. + * + * See issue #3250 + * See tests/electron/modules/calendar_spec.js + */ +let config = { + timeFormat: 12, + + modules: [ + { + module: "calendar", + position: "bottom_bar", + config: { + hideDuplicates: false, + maximumEntries: 100, + calendars: [ + { + maximumEntries: 100, + maximumNumberOfDays: 1, // Just today + url: "http://localhost:8080/tests/mocks/rrule_until.ics" + } + ] + } + } + ] +}; + +Date.now = () => { + return new Date("07 Mar 2024 10:38:00 GMT-07:00").valueOf(); +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/electron/modules/calendar_spec.js b/tests/electron/modules/calendar_spec.js index 3dcbd36f68..4e6aee17a2 100644 --- a/tests/electron/modules/calendar_spec.js +++ b/tests/electron/modules/calendar_spec.js @@ -44,6 +44,22 @@ describe("Calendar module", () => { }); }); + /****************************/ + // RRULE TESTS: + // Add any tests that check rrule functionality here. + describe("rrule", () => { + it("Issue #3393 recurrence dates past rrule until date", async () => { + await helpers.startApplication("tests/configs/modules/calendar/rrule_until.js", "07 Mar 2024 10:38:00 GMT-07:00", ["js/electron.js"], "America/Los_Angeles"); + expect(global.page).not.toBeNull(); + const loc = await global.page.locator(".calendar .event"); + const elem = loc.first(); + await elem.waitFor(); + expect(elem).not.toBeNull(); + const cnt = await loc.count(); + expect(cnt).toBe(1); + }); + }); + /****************************/ // LOS ANGELES TESTS: // In 2023, DST (GMT-7) was until 5 Nov, after which is standard (STD) (GMT-8) time. diff --git a/tests/mocks/rrule_until.ics b/tests/mocks/rrule_until.ics new file mode 100644 index 0000000000..cdb34e26e8 --- /dev/null +++ b/tests/mocks/rrule_until.ics @@ -0,0 +1,24 @@ +BEGIN:VEVENT +DTSTART;TZID=America/Los_Angeles:20240229T160000 +DTEND;TZID=America/Los_Angeles:20240229T190000 +RRULE:FREQ=WEEKLY;WKST=MO;UNTIL=20240307T075959Z;BYDAY=TH +DTSTAMP:20240307T180618Z +CREATED:20231231T000501Z +LAST-MODIFIED:20231231T005623Z +SEQUENCE:2 +STATUS:CONFIRMED +SUMMARY:My event +TRANSP:OPAQUE +END:VEVENT +BEGIN:VEVENT +DTSTART;TZID=America/Los_Angeles:20240307T160000 +DTEND;TZID=America/Los_Angeles:20240307T190000 +RRULE:FREQ=WEEKLY;WKST=MO;UNTIL=20240316T065959Z;BYDAY=TH +DTSTAMP:20240307T180618Z +CREATED:20231231T000501Z +LAST-MODIFIED:20231231T005623Z +SEQUENCE:3 +STATUS:CONFIRMED +SUMMARY:My event +TRANSP:OPAQUE +END:VEVENT \ No newline at end of file From a06ab29aa46014fa4fa7194b3d70322974154eb3 Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Thu, 7 Mar 2024 11:03:52 -0800 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8353ea0e3..1bb0524901 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ _This release is scheduled to be released on 2024-04-01._ - [newsfeed] Fix newsfeed stall issue introduced by #3336 (#3361) - Changed `log.debug` to `log.log` in `app.js` where logLevel is not set because config is not loaded at this time (#3353) - added message in case where config.js is missing the module.export line PR #3383 +- Fixed an issue where recurring events could extend past their recurrence end date (#3393) ### Deleted From 73b27e65763c45370a7a0c1d4904a17eb0ff5a4c Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Wed, 13 Mar 2024 08:16:17 -0700 Subject: [PATCH 4/4] PR feedback --- tests/configs/modules/calendar/rrule_until.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/configs/modules/calendar/rrule_until.js b/tests/configs/modules/calendar/rrule_until.js index f6768482ef..e553ebd194 100644 --- a/tests/configs/modules/calendar/rrule_until.js +++ b/tests/configs/modules/calendar/rrule_until.js @@ -1,11 +1,3 @@ -/* MagicMirror² Test calendar exdate - * - * By jkriegshauser - * MIT Licensed. - * - * See issue #3250 - * See tests/electron/modules/calendar_spec.js - */ let config = { timeFormat: 12,