From 90d6058b0f1d8779ddb33cdf6687d79187d6be8f Mon Sep 17 00:00:00 2001 From: Camille Moussu <66134347+Eriikah@users.noreply.github.com> Date: Thu, 18 Dec 2025 09:09:02 +0100 Subject: [PATCH] [#425] Event title modification of all day event alter event dates (#431) Co-authored-by: Camille Moussu --- __test__/features/Events/eventUtils.test.ts | 6 +++--- src/features/Events/EventDisplayPreview.tsx | 9 ++++++--- src/features/Events/EventUpdateModal.tsx | 1 + src/features/Events/eventUtils.ts | 5 ----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/__test__/features/Events/eventUtils.test.ts b/__test__/features/Events/eventUtils.test.ts index 2e2e84e..53d9170 100644 --- a/__test__/features/Events/eventUtils.test.ts +++ b/__test__/features/Events/eventUtils.test.ts @@ -513,12 +513,12 @@ describe("calendarEventToJCal", () => { ); }); - it("converts all-day events adjusting dtend", () => { + it("converts all-day events", () => { const mockEvent: any = { uid: "event-11", title: "All Day", start: "2025-07-21T00:00:00.000Z", - end: "2025-07-21T00:00:00.000Z", + end: "2025-07-22T00:00:00.000Z", timezone: "Europe/Paris", allday: true, attendee: [], @@ -542,7 +542,7 @@ describe("calendarEventToJCal", () => { calId: "test/test", title: "Team Meeting", start: "2025-07-23T00:00:00.000Z", - end: "2025-07-23T00:00:00.000Z", + end: "2025-07-24T00:00:00.000Z", timezone: "Europe/Paris", transp: "OPAQUE", class: "PUBLIC", diff --git a/src/features/Events/EventDisplayPreview.tsx b/src/features/Events/EventDisplayPreview.tsx index f3dd49a..475bce4 100644 --- a/src/features/Events/EventDisplayPreview.tsx +++ b/src/features/Events/EventDisplayPreview.tsx @@ -994,18 +994,21 @@ function formatEnd( const formatDatePart = (d: Date) => d.toLocaleDateString("en-CA", { timeZone }); // YYYY-MM-DD format - const sameDay = formatDatePart(startDate) === formatDatePart(endDate); - if (allday) { + const inclusiveEndDate = new Date(endDate); + inclusiveEndDate.setDate(inclusiveEndDate.getDate() - 1); + const sameDay = + formatDatePart(startDate) === formatDatePart(inclusiveEndDate); return sameDay ? null - : endDate.toLocaleDateString(t("locale"), { + : inclusiveEndDate.toLocaleDateString(t("locale"), { year: "numeric", month: "short", day: "numeric", timeZone, }); } else { + const sameDay = formatDatePart(startDate) === formatDatePart(endDate); if (sameDay) { return endDate.toLocaleTimeString(t("locale"), { hour: "2-digit", diff --git a/src/features/Events/EventUpdateModal.tsx b/src/features/Events/EventUpdateModal.tsx index cfafdb4..5ea7cd3 100644 --- a/src/features/Events/EventUpdateModal.tsx +++ b/src/features/Events/EventUpdateModal.tsx @@ -247,6 +247,7 @@ function EventUpdateModal({ if (isAllDay) { // For all-day events, use date format (YYYY-MM-DD) const endDate = new Date(event.end); + endDate.setDate(endDate.getDate() - 1); setEnd(endDate.toISOString().split("T")[0]); } else { // For timed events, format in the event's original timezone diff --git a/src/features/Events/eventUtils.ts b/src/features/Events/eventUtils.ts index 48d2de2..bf9c0cb 100644 --- a/src/features/Events/eventUtils.ts +++ b/src/features/Events/eventUtils.ts @@ -331,11 +331,6 @@ export function makeVevent( const endDate = new Date(event.end); let finalEndDate = endDate; - if (event.allday && endDate.getTime() === startDate.getTime()) { - finalEndDate = new Date(endDate); - finalEndDate.setDate(startDate.getDate() + 1); - } - vevent[1].push([ "dtend", { tzid },