From 886579942fe4f63fe5f2f509ecdfb1e58830db27 Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Tue, 21 Jul 2026 13:52:59 +0200 Subject: [PATCH] refactor(webui): use Core date-time formatting --- .../features/scheduling/SchedulingPage.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/webui/src/features/scheduling/SchedulingPage.tsx b/webui/src/features/scheduling/SchedulingPage.tsx index 26999cb..7f64bbd 100644 --- a/webui/src/features/scheduling/SchedulingPage.tsx +++ b/webui/src/features/scheduling/SchedulingPage.tsx @@ -18,6 +18,7 @@ import { DataGridEmptyAction, DataGridRowActions, DateTimeField, + formatDateTime, ModuleSubnav, SelectionList, SelectionListItem, @@ -31,6 +32,7 @@ import { type AuthInfo, type CalendarPickerUiCapability, type DataGridColumn, + type FormatDateTimeOptions, type ModuleSubnavGroup } from "@govoplan/core-webui"; import { @@ -1064,8 +1066,8 @@ function CandidateSlotsGrid({ ) }, - { id: "start", header: I18N.start, minWidth: 160, resizable: true, value: (slot) => slot.start_at, render: (slot) => formatDateTime(slot.start_at) }, - { id: "end", header: I18N.end, minWidth: 160, resizable: true, value: (slot) => slot.end_at, render: (slot) => formatDateTime(slot.end_at) }, + { id: "start", header: I18N.start, minWidth: 160, resizable: true, value: (slot) => slot.start_at, render: (slot) => formatDateTime(slot.start_at, SHORT_DATE_TIME_OPTIONS) }, + { id: "end", header: I18N.end, minWidth: 160, resizable: true, value: (slot) => slot.end_at, render: (slot) => formatDateTime(slot.end_at, SHORT_DATE_TIME_OPTIONS) }, { id: "available", header: I18N.available, @@ -1235,17 +1237,24 @@ function isoFromLocal(value: string): string { return new Date(value).toISOString(); } -function formatDateTime(value: string): string { - return new Intl.DateTimeFormat(undefined, { dateStyle: "short", timeStyle: "short" }).format(new Date(value)); -} +const SHORT_DATE_TIME_OPTIONS: FormatDateTimeOptions = { + year: undefined, + month: undefined, + day: undefined, + hour: undefined, + minute: undefined, + timeZoneName: undefined, + dateStyle: "short", + timeStyle: "short" +}; function formatRange(start: string, end: string): string { - return `${formatDateTime(start)} – ${formatDateTime(end)}`; + return `${formatDateTime(start, SHORT_DATE_TIME_OPTIONS)} – ${formatDateTime(end, SHORT_DATE_TIME_OPTIONS)}`; } function formatRelevantDate(request: SchedulingRequest): string { const timestamp = schedulingRelevantTimestamp(request); - return Number.isFinite(timestamp) ? formatDateTime(new Date(timestamp).toISOString()) : ""; + return Number.isFinite(timestamp) ? formatDateTime(new Date(timestamp).toISOString(), SHORT_DATE_TIME_OPTIONS) : ""; } function errorMessage(error: unknown, fallback: string): string {