Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 3393 #3395

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions modules/default/calendar/calendarfetcherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions tests/configs/modules/calendar/rrule_until.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* MagicMirror² Test calendar exdate
jkriegshauser marked this conversation as resolved.
Show resolved Hide resolved
*
* 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;
}
16 changes: 16 additions & 0 deletions tests/electron/modules/calendar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions tests/mocks/rrule_until.ics
Original file line number Diff line number Diff line change
@@ -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
Loading