mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Up to v1.4.24 the snapshot's day-key and weekday labels ran through utcDayKey() / utcWeekday() / isoWeekKey(), so a 23:50 Pacific/Auckland reading was filed under the next UTC day and the Coach replied with the wrong calendar. The pipeline now reads User.timezone (alongside the existing coachPrefsJson read so the read budget is unchanged) and threads it through every bucketing helper (dailyMeans, bucketWeekly, buildDailyValueRows, buildDailyBpRows) plus the medication-compliance day-roll-up and the Apple Health additive blocks. The prompt-budget calculator (src/lib/ai/coach/budget.ts) is unaffected. The ledger still uses UTC midnight for spend roll-over because the operator's LLM bill cycles on UTC; only the SNAPSHOT itself shifts to the user's calendar. The provenance counts are row counts, not day counts, so no provenance drift either. Integration test pins the boundary: a 13:00 UTC May 14 reading (= 01:00 NZST May 15) appears under "2026-05-15" in the Coach snapshot for a Pacific/Auckland user. The same instant in Berlin would land on May 14; the test asserts the snapshot does NOT bucket there. Existing 88-test coach unit suite stays green (the mocked user row returns no timezone, so the snapshot falls back to Europe/Berlin and the v1.4.24 byte-shape holds).