From bd2f982c489b15ce1165c051fdedf35af979f784 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 8 Sep 2026 17:06:51 +0200 Subject: Migrate date handling from Date to Temporal API Routine scheduling, health series, service stamps, session expiry, and date formatting move to native Temporal (Instant / ZonedDateTime in UTC), with ISO strings kept at DB and chart boundaries. Ambient types in src/temporal-ambient.d.ts cover the native runtime; no polyfill. Observable behavior and stored formats are unchanged. --- src/lib/shared/temporal.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/lib/shared/temporal.ts (limited to 'src/lib/shared/temporal.ts') diff --git a/src/lib/shared/temporal.ts b/src/lib/shared/temporal.ts new file mode 100644 index 0000000..7097ba3 --- /dev/null +++ b/src/lib/shared/temporal.ts @@ -0,0 +1,27 @@ +// Shared Temporal display helpers. Storage and logic stay in ISO instants; +// these format one for the viewer in their own timezone. + +/** Format an ISO instant in the viewer's timezone. */ +export function formatInstant( + iso: string, + options: Intl.DateTimeFormatOptions, +): string { + return Temporal.Instant.from(iso) + .toZonedDateTimeISO(Temporal.Now.timeZoneId()) + .toLocaleString('fr-FR', options); +} + +/** Short day-month stamp ("8 sept."). */ + +export function formatDayMonth(iso: string): string { + return formatInstant(iso, { day: 'numeric', month: 'short' }); +} + +/** Day-month-year stamp ("8 sept. 2026"). */ +export function formatDayMonthYear(iso: string): string { + return formatInstant(iso, { + day: 'numeric', + month: 'short', + year: 'numeric', + }); +} -- cgit v1.3