From 3c0db7877c94b2ef3abff682bfb62ccc8cf6717d Mon Sep 17 00:00:00 2001 From: Massedil Date: Wed, 6 Nov 2024 18:22:58 +0100 Subject: [PATCH] Issue #1511: Date display problem : - the time zone is used to calculate the date - use the offset to know if beginsOn and endsOn are the same day - refactor the Solves, for example, this display problem : The date range "2024-12-31 17:45 to 2025-01-01 01:00" in the Asia/Shanghai time zone (spanning different years and days) is equivalent to "2024-12-31 at 10:45 to 2024-12-31 at 18:00" in the Europe/Paris time zone (same year and same day). --- src/components/Event/EventFullDate.vue | 110 +++++++++---------------- src/filters/datetime.ts | 5 +- 2 files changed, 41 insertions(+), 74 deletions(-) diff --git a/src/components/Event/EventFullDate.vue b/src/components/Event/EventFullDate.vue index 30354084d..74494df8f 100644 --- a/src/components/Event/EventFullDate.vue +++ b/src/components/Event/EventFullDate.vue @@ -3,14 +3,6 @@ {{ formatDateTimeString(beginsOn, timezoneToShow, showStartTime) }} -
- - {{ singleTimeZone }} -

diff --git a/src/filters/datetime.ts b/src/filters/datetime.ts index a11933e21..c1f812739 100644 --- a/src/filters/datetime.ts +++ b/src/filters/datetime.ts @@ -8,12 +8,13 @@ function formatDateISOStringWithoutTime(value: string): string { return parseDateTime(value).toISOString().split("T")[0]; } -function formatDateString(value: string): string { +function formatDateString(value: string, timeZone?: string): string { return parseDateTime(value).toLocaleString(locale(), { weekday: "long", year: "numeric", month: "long", day: "numeric", + timeZone: timeZone, }); } @@ -21,7 +22,7 @@ function formatTimeString(value: string, timeZone?: string): string { return parseDateTime(value).toLocaleTimeString(locale(), { hour: "numeric", minute: "numeric", - timeZone, + timeZone: timeZone, }); }