From 262c5ede9bf0eaa509c24021695d8a18e80cd11a Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Mon, 22 Jan 2024 12:05:43 -0800 Subject: [PATCH] Fix an issue where a specific recurrence screws up duration for following events --- modules/default/calendar/calendarfetcherutils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/default/calendar/calendarfetcherutils.js b/modules/default/calendar/calendarfetcherutils.js index b8f77c3710..d72c1f4e96 100644 --- a/modules/default/calendar/calendarfetcherutils.js +++ b/modules/default/calendar/calendarfetcherutils.js @@ -188,7 +188,7 @@ const CalendarFetcherUtils = { Log.debug(`end:: ${endMoment.toDate()}`); // Calculate the duration of the event for use with recurring events. - let durationMs = endMoment.valueOf() - startMoment.valueOf(); + const durationMs = endMoment.valueOf() - startMoment.valueOf(); Log.debug(`duration: ${durationMs}`); // FIXME: Since the parsed json object from node-ical comes with time information @@ -365,6 +365,7 @@ const CalendarFetcherUtils = { for (let d in dates) { let date = dates[d]; let curEvent = event; + let curDurationMs = durationMs; let showRecurrence = true; startMoment = moment(date); @@ -381,16 +382,16 @@ const CalendarFetcherUtils = { // We found an override, so for this recurrence, use a potentially different title, start date, and duration. curEvent = curEvent.recurrences[dateKey]; startMoment = moment(curEvent.start); - durationMs = curEvent.end.valueOf() - startMoment.valueOf(); + curDurationMs = curEvent.end.valueOf() - startMoment.valueOf(); } // If there's no recurrence override, check for an exception date. Exception dates represent exceptions to the rule. else if (curEvent.exdate !== undefined && curEvent.exdate[dateKey] !== undefined) { // This date is an exception date, which means we should skip it in the recurrence pattern. showRecurrence = false; } - Log.debug(`duration: ${durationMs}`); + Log.debug(`duration: ${curDurationMs}`); - endMoment = moment(startMoment.valueOf() + durationMs); + endMoment = moment(startMoment.valueOf() + curDurationMs); if (startMoment.valueOf() === endMoment.valueOf()) { endMoment = endMoment.endOf("day"); }