Skip to content

Commit 2d3a557

Browse files
fix(calendar): update to node-ical 0.23.1 and fix full-day recurrence lookup (#4013)
Adapts calendar module to node-ical changes and fixes a bug with moved full-day recurring events in eastern timezones. ## Changes ### 1. Update node-ical to 0.23.1 - Includes upstream fixes for UNTIL UTC validation errors from CalDAV servers (reported by @rejas in PR #4010) - Changes to `getDateKey()` behavior for VALUE=DATE events (now uses local date components) - Fixes issue with malformed DURATION values (reported by MagicMirror user here: jens-maus/node-ical#381) ### 2. Remove dead code - Removed ineffective UNTIL modification code (rule.options is read-only in rrule-temporal) - The code attempted to extend UNTIL for all-day events but had no effect ### 3. Fix recurrence lookup for full-day events node-ical changed the behavior of `getDateKey()` - it now uses local date components for VALUE=DATE events instead of UTC. This broke recurrence override lookups for full-day events in eastern timezones. **Why it broke:** - **before node-ical update:** Both node-ical and MagicMirror used UTC → keys matched ✅ - **after node-ical update:** node-ical uses local date (RFC 5545 conform), MagicMirror still used UTC → **mismatch** ❌ **Example:** - Full-day recurring event on October 12 in Europe/Berlin (UTC+2) - node-ical 0.23.1 stores override with key: `"2024-10-12"` (local date) - MagicMirror looked for key: `"2024-10-11"` (from UTC: Oct 11 22:00) - **Result:** Moved event not found, appears on wrong date **Solution:** Adapt to node-ical's new behavior by using local date components for full-day events, UTC for timed events. **Note:** This is different from previous timezone fixes - those addressed event generation, this fixes the lookup of recurrence overrides. ## Background node-ical 0.23.0 switched from `rrule` to `rrule-temporal`, introducing breaking changes. Version 0.23.1 fixed the UNTIL validation issue and formalized the `getDateKey()` behavior for DATE vs DATE-TIME values, following RFC 5545 specification that DATE values represent local calendar dates without timezone context.
1 parent 82e39a2 commit 2d3a557

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

modules/default/calendar/calendarfetcherutils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ const CalendarFetcherUtils = {
6666
const searchFromDate = pastLocalMoment.clone().subtract(Math.max(durationInMs, oneDayInMs), "milliseconds").toDate();
6767
const searchToDate = futureLocalMoment.clone().add(1, "days").toDate();
6868

69-
// For all-day events, extend "until" to end of day to include the final occurrence
70-
if (isFullDayEvent && rule.options?.until) {
71-
rule.options.until = moment(rule.options.until).endOf("day").toDate();
72-
}
73-
7469
const dates = rule.between(searchFromDate, searchToDate, true) || [];
7570

7671
// Convert dates to moments in the event's timezone.
@@ -313,7 +308,12 @@ const CalendarFetcherUtils = {
313308
let recurringEventStartMoment = startMoment.clone().tz(CalendarFetcherUtils.getLocalTimezone());
314309
let recurringEventEndMoment = recurringEventStartMoment.clone().add(durationMs, "ms");
315310

316-
const dateKey = recurringEventStartMoment.tz("UTC").format("YYYY-MM-DD");
311+
// For full-day events, use local date components to match node-ical's getDateKey behavior
312+
// For timed events, use UTC to match ISO string slice
313+
const isFullDay = CalendarFetcherUtils.isFullDayEvent(event);
314+
const dateKey = isFullDay
315+
? recurringEventStartMoment.format("YYYY-MM-DD")
316+
: recurringEventStartMoment.tz("UTC").format("YYYY-MM-DD");
317317

318318
// Check for overrides
319319
if (curEvent.recurrences !== undefined) {

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"ipaddr.js": "^2.3.0",
9393
"moment": "^2.30.1",
9494
"moment-timezone": "^0.6.0",
95-
"node-ical": "^0.23.0",
95+
"node-ical": "^0.23.1",
9696
"nunjucks": "^3.2.4",
9797
"pm2": "^6.0.14",
9898
"socket.io": "^4.8.3",

0 commit comments

Comments
 (0)