mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
fix(format): honour the time-format preference on every clock renderer
The H24 / H12 preference only reached makeFormatters().time. Surfaces that build their own Intl.DateTimeFormat — the sleep hypnogram axis, the workout list and detail headers — omitted the hour cycle, so an en-locale (or AUTO) user saw AM/PM even with H24 selected. The security activity feed and session list rendered raw toLocaleString(), bypassing both the locale and the preference entirely. Export hourCycleOptions from format-locale as the single source for the H12 / H24 / AUTO Intl options and spread it into the self-built formatters, preserving each surface's locale and timezone. Route the security cards through useFormatters().dateTime. Drop the date-time field's local copy of the helper. Guards: the helper contract, the en-US hour/minute call-site pattern (no AM/PM under H24, AM/PM under H12), and formatUpdatedLabel fed an H24 formatter for the briefing freshness label.
This commit is contained in:
1 parent
78fec1ceff
commit
0d45d0ab53
9 files changed
+131
-26
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
useTimeFormatPreference,
|
||||
} from "@/lib/i18n/context";
|
||||
import { formatDate, resolveDateLocale } from "@/lib/date-format";
|
||||
import { hourCycleOptions } from "@/lib/format-locale";
|
||||
|
||||
/**
|
||||
* Dependency-free datetime input that DISPLAYS the value in the user's
|
||||
@@ -221,20 +222,6 @@ function formatLocalDateTime(
|
||||
return `${datePart} ${timePart}`;
|
||||
}
|
||||
|
||||
/** Mirror of `format-locale.ts` `hourCycleOptions`, kept local to the field. */
|
||||
function hourCycleOptions(
|
||||
timeFormat: ReturnType<typeof useTimeFormatPreference>,
|
||||
): Intl.DateTimeFormatOptions {
|
||||
switch (timeFormat) {
|
||||
case "H12":
|
||||
return { hour12: true };
|
||||
case "H24":
|
||||
return { hourCycle: "h23" };
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/** Split a local `yyyy-MM-ddTHH:mm` string into its calendar parts. */
|
||||
function parseLocalDateTime(value: string): {
|
||||
date: string;
|
||||
|
||||
Reference in new issue
Block a user