mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Day keys and wall-clock fields are computed per row in the analytics, digest and personal-record loops, and each call ran Intl.DateTimeFormat#formatToParts plus a resolvedOptions() allocation to re-validate the zone. In a CPU profile of an Insights page load the zone helpers were 17-19% of the busy time on the request thread. Probe the offset once per UTC hour at both ends of the hour and derive the wall clock arithmetically; an hour that contains a transition, an instant outside 1971-2199 or an invalid date keeps the formatter path. Zone validity is memoised per name. userDayKey drops from 9.3 to 1.5 us per call, wallClockInTz from 6.4 to 0.5 us; a parity test checks the result against Intl around every 2026 transition in ten zones.