fix(ui): own the time picker so it follows the 24-hour preference

The native datetime-local / time picker renders its clock and AM/PM
toggle by the browser UI language, not the page lang or the app's
time-format preference — so an English-language browser showed AM/PM
even with 24-hour selected. Replace the native time control with an
app-controlled TimeField (text entry + a dependency-free popover of
hour/minute, plus AM/PM in 12-hour mode) whose hour cycle always tracks
the preference. DateTimeField now composes the native calendar (date)
with TimeField (time); the committed value stays a local
yyyy-MM-ddTHH:mm string, and min/max clamp the recombined value.

Also thread the time-format preference into the doctor-report PDF so its
generated-at timestamp honours it instead of the locale default.
This commit is contained in:
Marc-André Bombeck committed 2026-06-29 19:03:47 +02:00
1 parent 426b21497a
commit 7e901e674a
19 files changed
+826 -243

No files matched your search

+10 -2
View File
@@ -12,7 +12,7 @@
import { jsPDF } from "jspdf";
import autoTable from "jspdf-autotable";
import { DOCTOR_REPORT_TYPE_LABEL_KEYS } from "./doctor-report/type-label-keys";
import { makeFormatters } from "./format-locale";
import { makeFormatters, type TimeFormatPreference } from "./format-locale";
import type { Locale } from "./i18n/config";
import { convertGlucose, resolveGlucoseUnit } from "./glucose";
import {
@@ -130,6 +130,13 @@ export interface DoctorReportRenderOptions {
* Eastern-time rows even when generated in the browser.
*/
userTz?: string;
/**
* v1.25.4 — the user's hour-cycle preference. Threaded into the formatters
* so the footer "generated at" timestamp (and any other clock the report
* prints) honours H12 / H24 rather than falling to the locale default. When
* omitted it stays AUTO (locale default), matching the legacy contract.
*/
timeFormat?: TimeFormatPreference;
/**
* v1.7.0 — decrypted KVNR (German insurance number). Printed on the
* cover when present; the column is encrypted at rest, so the route
@@ -474,11 +481,12 @@ export function buildDoctorReportPdfDocument(
locale,
now = new Date(),
userTz,
timeFormat = "AUTO",
insuranceNumber = null,
includeCharts = true,
aiSummary = null,
} = options;
const formatters = makeFormatters(locale, userTz);
const formatters = makeFormatters(locale, userTz, timeFormat);
const num = (value: number, decimals = 1) =>
formatters.number(value, decimals);
const fmtDate = (iso: string) => formatters.date(iso);