mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
chore(release): v1.28.35 — timestamps honor the profile timezone
Client-rendered times fell back to the hardcoded display zone (Europe/Berlin) because neither useFormatters() nor the legacy format.ts helpers ever received users.timezone. A third localStorage mirror (timezone-mirror.ts, following the time-format/date-format pattern) carries the validated profile zone from /api/auth/me into both read paths; the fallback chain is strictly profile → Europe/Berlin — never the browser zone, so screen, PDF, and export cannot disagree. makeFormatters validates its zone before Intl (a poison value falls back instead of throwing inside every render). Same pass, per the two-document audit: formatUpdatedLabel boundary and clock now resolve one zone in every state (the undefined-tz browser hole is closed); @db.Date calendar fields render UTC-pinned so profiles west of UTC cannot shift a day; dose-history day headings and GLP-1 weekday labels derive from the display zone; chart day/month labels are encoding-derived and UTC-pinned (bucket math untouched, byte-identical for Berlin profiles); the clinician share view renders in the patient's timezone instead of the container's; Playwright pins Europe/Berlin. Server day-key semantics, streak anchoring, insight cache keys, and verbatim wall-clock strings are untouched by construction and pinned by the new Auckland/New_York/Manila + DST test matrix.
This commit is contained in:
1 parent
136653e3d7
commit
9bbd8a89dc
41 files changed
+958
-90
No files matched your search
@@ -139,6 +139,34 @@ export function formatDate(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a plain calendar date (ISO `yyyy-MM-dd` day key or a Date) as
|
||||
* short weekday + day + month — the `fmt.dateWithWeekday` field set
|
||||
* ("Di., 14.07." / "Tue, 07/14") — pinned to UTC like {@link formatDate}.
|
||||
*
|
||||
* Issue #490: for a value that is a DAY KEY (e.g. the dose-history
|
||||
* ledger's profile-timezone day groups), parsing it as a local-midnight
|
||||
* instant and re-formatting through a timezone-aware formatter can shift
|
||||
* the rendered day when browser and profile zones differ. The calendar
|
||||
* date (and therefore its weekday) is already fully determined by the
|
||||
* key, so it renders UTC-pinned — correct in every zone, no DST edge.
|
||||
*/
|
||||
export function formatDateWithWeekday(
|
||||
value: Date | string | null | undefined,
|
||||
pref: DateFormatPreference,
|
||||
locale: Locale,
|
||||
): string {
|
||||
if (value === null || value === undefined || value === "") return "";
|
||||
const date = value instanceof Date ? value : parseIsoDate(value);
|
||||
if (date === null || Number.isNaN(date.getTime())) return "";
|
||||
return date.toLocaleDateString(resolveDateLocale(pref, locale), {
|
||||
timeZone: "UTC",
|
||||
weekday: "short",
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a `yyyy-MM-dd` string to a UTC `Date` at midnight. Returns null on
|
||||
* a value that is not exactly the ISO calendar-date shape so callers can
|
||||
|
||||
Reference in new issue
Block a user