Skip to content

Commit

Permalink
Fix issue 3393 (#3395)
Browse files Browse the repository at this point in the history
Fix for #3393
  • Loading branch information
jkriegshauser committed Mar 13, 2024
1 parent 90ff340 commit 1a745cf
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
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
30 changes: 30 additions & 0 deletions tests/configs/modules/calendar/rrule_until.js
Original file line number Diff line number Diff line change
@@ -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;
}
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

0 comments on commit 1a745cf

Please sign in to comment.