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 <o-switch>

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).
This commit is contained in:
Massedil
2024-11-06 18:22:58 +01:00
parent 0fa7a20414
commit 3c0db7877c
2 changed files with 41 additions and 74 deletions

View File

@@ -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,
});
}