From 0fded45c7604e5df546418e9e7bfdc0c6245d1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Daase?= Date: Tue, 15 Feb 2022 11:21:48 +0100 Subject: [PATCH] dateMenu: Don't manipulate passed events The event passed to formatEventTime() is reused at a later point. Therefore, we are not allowed to manipulate the event directly. This fixes an issue where the user clicks on a multi-day all-day event the second time before the event gets garbage collected and the event then is one day shorter. Fixes 528ee01fef6e5ca2303fc766be29a854d8ee928b Part-of: --- js/ui/dateMenu.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 8ed1a579b..55c12ebe1 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -175,7 +175,7 @@ class EventsSection extends St.Button { _formatEventTime(event) { const eventStart = event.date; - const eventEnd = event.end; + let eventEnd = event.end; const allDay = eventStart.getTime() === this._startDate.getTime() && eventEnd.getTime() === this._endDate.getTime(); @@ -203,8 +203,10 @@ class EventsSection extends St.Button { const startYear = eventStart.getFullYear(); - if (endsAtMidnight) + if (endsAtMidnight) { + eventEnd = new Date(eventEnd); eventEnd.setDate(eventEnd.getDate() - 1); + } const endYear = eventEnd.getFullYear();