fix(format): carry the date-order preference to every numeric date - #925
Merged
Conversation
The per-user date order reached the entry form and nothing else. A reporter switched away from MM/DD/YYYY, the date picker followed, and the dashboard chart axes and the measurements list kept the old order. `makeFormatters` took `timeFormat` and `dateFormat` as optional parameters defaulting to "AUTO", so six of the seven constructions in the tree silently rendered the locale default and nothing anywhere said the setting had been dropped. Drop both defaults. The compiler then names every caller: the chart bucket labels, the legacy `@/lib/format` helpers the measurements list renders through, the medication compliance and efficacy charts, the doctor-report PDF and the clinician share view. Thread the preference: - `makeBucketLabelFormatters` takes the order; the health and mood charts read `useDateFormatPreference()`. The UTC pin decides which day the label names, the preference decides how it is spelled, and the two are separate questions. - `format.ts` reads `readStoredDateFormat()` beside the timezone and hour-cycle mirrors it already read. - The PDF takes `dateFormat` as a required render option, alongside `timeFormat`, which was optional for the same reason. - The clinician share view spells the OWNER's dates the owner's way. It also picked up the owner's hour cycle, which it had been ignoring while the PDF route beside it already honoured it. Both resolve through the new `resolveUserFormatPreferences`, the counterpart to `resolveUserTimezone`. Textual months stay on the UI locale. The preference pins numeric field order by rendering through de-DE / en-US / en-CA, and a textual month through those would change the month name's language. Add `date-order-explicit-formatter-guard`: a raw numeric date renderer must take its locale from the preference or carry a written reason, and a formatter construction may not hard-code "AUTO" for the order. Its allowlist holds thirteen calendar-day key builders, each with the reason it has no order to get wrong. The sibling timezone guard passes every one of them, because naming a calendar says nothing about spelling a date. Refs #922
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A reporter switched the date order away from MM/DD/YYYY. The entry form followed; the dashboard chart axes and the measurements list did not (#922).
The preference reached exactly one place.
makeFormatterstooktimeFormatanddateFormatas optional parameters defaulting to AUTO, so six of the seven constructions in the tree silently rendered the locale default and nothing said the setting had been dropped. Both defaults are gone; the compiler then named every caller: the chart bucket labels, the legacy format helpers the measurements list renders through, the medication compliance and efficacy charts, the doctor-report PDF and the clinician share view. Each now carries the preference, and the share view spells the owner's dates the owner's way, which also fixed the owner's hour cycle there, ignored while the PDF route beside it honoured it.Textual months stay on the UI language on purpose: the preference pins numeric field order by rendering through a canonical locale, and a month name through that locale would change language. Every raw date site named in the audit turned out to be a calendar-day key or a dedup key rather than a rendered label; each is on the new guard's allowlist with that reason written down.
The guard,
date-order-explicit-formatter-guard, refuses a numeric date renderer that does not take its locale from the preference and a formatter construction that hard-codes AUTO. The sibling timezone guard passes every one of those sites, because naming a calendar says nothing about spelling a date.Reproduced first: the axis label and the measurements string under DMY showed the wrong order before the change. Per-surface tests assert field order under DMY, MDY and YMD. Gate: typecheck, lint at the three documented warnings, format, contract in sync, unit suite green twice, integration suite run on the rebased branch.
Refs #922