Skip to content

Commit 3b793bf

Browse files
Update node-ical and support it's rrule-temporal changes (MagicMirrorOrg#4010)
Updating `node-ical` and adapt logic to new behaviour. ## Problem node-ical 0.23.0 switched from `rrule.js` to `rrule-temporal`, changing how recurring event dates are returned. Our code assumed the old behavior where dates needed manual timezone conversion. ## Solution Updated `getMomentsFromRecurringEvent()` in `calendarfetcherutils.js`: - Removed `tzid = null` clearing (no longer needed) - Simplified timed events: `moment.tz(date, eventTimezone)` instead of `moment.tz(date, "UTC").tz(eventTimezone, true)` - Kept UTC component extraction for full-day events to prevent date shifts
1 parent 471dbd8 commit 3b793bf

3 files changed

Lines changed: 402 additions & 249 deletions

File tree

modules/default/calendar/calendarfetcherutils.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,15 @@ const CalendarFetcherUtils = {
7171
rule.options.until = moment(rule.options.until).endOf("day").toDate();
7272
}
7373

74-
// Clear tzid to prevent rrule.js from double-adjusting times
75-
if (rule.options) {
76-
rule.options.tzid = null;
77-
}
78-
7974
const dates = rule.between(searchFromDate, searchToDate, true) || [];
8075

81-
// Convert dates to moments in the appropriate timezone
82-
// rrule.js returns UTC dates with tzid cleared, so we interpret them in the event's original timezone
76+
// Convert dates to moments in the event's timezone.
77+
// Full-day events need UTC component extraction to avoid date shifts across timezone boundaries.
8378
return dates.map((date) => {
8479
if (isFullDayEvent) {
85-
// For all-day events, extract UTC date components and interpret as local calendar date
86-
// This prevents timezone offsets from shifting the date to the previous/next day
87-
const utcYear = date.getUTCFullYear();
88-
const utcMonth = date.getUTCMonth();
89-
const utcDate = date.getUTCDate();
90-
return moment.tz([utcYear, utcMonth, utcDate], eventTimezone);
80+
return moment.tz([date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], eventTimezone);
9181
}
92-
// For timed events, preserve the time in the event's original timezone
93-
return moment.tz(date, "UTC").tz(eventTimezone, true);
82+
return moment.tz(date, eventTimezone);
9483
});
9584
},
9685

0 commit comments

Comments
 (0)