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 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 diff --git a/tests/configs/modules/calendar/rrule_until.js b/tests/configs/modules/calendar/rrule_until.js new file mode 100644 index 0000000000..e553ebd194 --- /dev/null +++ b/tests/configs/modules/calendar/rrule_until.js @@ -0,0 +1,30 @@ +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