Skip to content

fix(i18n): harden date locale handling - #5303

Merged
nynexman4464 merged 4 commits into
mainfrom
nynexman4464/fix/date-locale-followup
Aug 27, 2026
Merged

nynexman4464 merged 4 commits into
mainfrom
nynexman4464/fix/date-locale-followup

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Default pure date helpers to deterministic English and Gregorian semantics while preserving the low-level plainDateFormat API’s explicit calendar option for compatibility.
  • Read the live provider locale across Calendar and every DateInput surface, including touch-picker rerenders and navigation.
  • Keep Gregorian date semantics across Timestamp, PowerSearch, both chart packages, and every Schedule view while preserving localized language, numbering, and field order.
  • Require production date-helper calls to pass locale explicitly, with import-aware coverage for named imports, aliases, and namespaces.

Visual evidence

French and Thai Calendar, DateInput, and Timestamp output from the updated head. Both follow the provider locale; Thai remains in Gregorian year 2026 rather than Buddhist year 2569.

French and Thai Gregorian date formatting

Verification

  • Red/green proof: the new Lab Chart and Schedule cases produced 3 locale failures at the previous head; the compatibility test also fails against a silent calendar override (2026 instead of 2569 BE). All 395 focused date tests now pass.
  • Core, charts, Lab, and production Storybook builds pass; Storybook type-check passes.
  • pnpm lint:strict passes with 0 errors (80 pre-existing warn-tier findings).
  • The full UI run passed all functional tests. Its unrelated 500-row Table benchmark exceeded the budget once under parallel load (536 ms); the isolated rerun passed at 310 ms against the 500 ms budget.

@vercel

vercel Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 27, 2026 6:30pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 21, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/date-locale-followup branch from dce84a5 to 32e5c93 Compare August 21, 2026 19:36
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Calendar (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1476 -
Complexity N/A Very High (138) -
DateInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3296 -
Complexity N/A Very High (356) -
DateRangeInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 539 -
Complexity N/A Very High (66) -
DateTimeInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1236 -
Complexity N/A Very High (237) -
PowerSearch (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3847 -
Complexity N/A Very High (342) -
Timestamp (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 686 -
Complexity N/A Very High (80) -
Chart (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3471 -
Complexity N/A Very High (374) -
Schedule (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3384 -
Complexity N/A Very High (187) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB
@astryxdesign/lab N/A 3.5KB 1.5KB
@astryxdesign/charts N/A 922B 436B

Accessibility Audit

Status: 3 accessibility violation(s) found — 1 critical, 2 serious.

DateRangeInput - 1 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/20 stories · Learn more
    • WCAG: 4.1.2 (Level A)
PowerSearch - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Timestamp - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/19 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

Status: Skipped — Broad stable scope is deferred to the daily release gate. It covers 974 trusted baseline shots instead of recapturing them for this PR. View the report


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for chasing this down — six unthreaded call sites were real, and the rerender tests are the right proof.

Ideally I'd like to avoid the Gregorian default. None of our 30 shipped locales move under it, but Locale is any tag: set th-TH and someone reading one screen gets 22 สิงหาคม 2026 in the field and 2569 in the <Timestamp> beside it, because only DateInput goes through plainDateFormat. Thai Buddhist months line up with Gregorian, so that year was right before.

before after

Persian is the case that wanted it, and that's the Calendar grid's fact rather than the formatter's:

plainDateFormat(m, {...DATE_FORMAT_MONTH_YEAR, calendar: 'gregory'}, locale)

Everything else lands as it stands, and #5296's hydration paragraph is worth lifting into the changeset.

Does pinning the three grid headers cover it, or is there a case that needs the formatter itself pinned?

[Reviewed by Robohands]

@cixzhang

Copy link
Copy Markdown
Contributor

Inline, packages/core/src/utils/plainDate.ts:324 — Timestamp doesn't come through here, so a th-TH field says 2026 while the Timestamp beside it says 2569.

@nynexman4464

Copy link
Copy Markdown
Contributor Author

Gregorian is intentional here, not a fallback chosen for one locale.

Astryx's current date contract is Gregorian end to end: ISO/PlainDate values, parsing, arithmetic, constraints, and Calendar navigation all use Gregorian fields. locale controls language, numbering, and field order; it does not enable another calendar system. Letting raw Intl calls infer a calendar from th-TH or a u-ca-* extension would change display output without changing those underlying semantics, producing partial support and conflicting values between components.

This update therefore keeps calendar: 'gregory' across every shipped date formatter, including Timestamp, PowerSearch, chart formatters, and Schedule. For example, th-TH still localizes the date text, but the year remains Gregorian 2026.

Alternative-calendar support needs an explicit contract for demand, calendar selection and runtime switching, conversion, parsing, storage/serialization, grid arithmetic, constraints, and accessibility. That design is being tracked separately in #5498; until it is resolved, Gregorian is the only supported calendar system.

github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/date-locale-followup branch from 5766a2f to 843b768 Compare August 25, 2026 16:29
github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/date-locale-followup branch from 843b768 to a84aa14 Compare August 25, 2026 19:24
github-actions Bot added a commit that referenced this pull request Aug 25, 2026
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/date-locale-followup branch from a84aa14 to 1ab1381 Compare August 25, 2026 20:16
@nynexman4464 nynexman4464 changed the title fix(core): harden date locale handling fix(i18n): harden date locale handling Aug 25, 2026
github-actions Bot added a commit that referenced this pull request Aug 25, 2026

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — this fixes the DateInput/Timestamp split I called out: the new head makes every date formatter Gregorian, and the focused browser pair now shows both Thai surfaces on 2026.

One API edge still needs fixing before merge. plainDateFormat accepts calendar inside Intl.DateTimeFormatOptions, then silently overwrites it; the new test proves calendar: 'buddhist' compiles but returns Gregorian. Could we remove calendar from the accepted options type so the Gregorian-only contract fails at compile time?

Full review

[Reviewed by Robohands]

Comment thread packages/core/src/utils/plainDate.ts Resolved
josephfarina and others added 4 commits August 27, 2026 11:21
plainDateFormat passed undefined to Intl.DateTimeFormat, so the locale
resolved to whatever the runtime had. Across an SSR boundary that can differ
and produce a hydration mismatch.

Default to 'en', matching what useLocale() returns outside a provider, while
keeping the optional locale parameter for provider-aware callers.
@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/date-locale-followup branch from 1ab1381 to a3ab868 Compare August 27, 2026 18:26
@github-actions
github-actions Bot requested a review from cixzhang August 27, 2026 18:26
@nynexman4464

Copy link
Copy Markdown
Contributor Author

Thanks — I agree that silently overriding calendar is the wrong API behavior, but narrowing the accepted type would be source-breaking here. plainDateFormat is publicly exported from @astryxdesign/core/utils, and its second parameter has always been the full Intl.DateTimeFormatOptions, including calendar.

I changed the contract instead:

  • omitted options.calendar defaults to gregory;
  • an explicitly supplied options.calendar is preserved for compatibility;
  • the exception is display-only: PlainDate arithmetic, parsing, serialization, Calendar/DateInput navigation, Timestamp, both chart formatter packages, PowerSearch, and Schedule remain Gregorian.

I audited the public surface and plainDateFormat is the only Astryx built-in date API that exposes raw calendar selection. Consumer-provided custom format callbacks are still consumer-owned escape hatches, not Astryx calendar support.

The new regression test fails against the silent override (2026 instead of 2569 BE) and passes with the compatibility behavior. I also documented this limited exception and its boundaries in #5498.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — honoring an explicit calendar closes the public API edge, while every Astryx date surface stays Gregorian. This is good now.

[Reviewed by Robohands]

@nynexman4464
nynexman4464 merged commit 2458b03 into main Aug 27, 2026
28 of 29 checks passed
@github-actions
github-actions Bot deleted the nynexman4464/fix/date-locale-followup branch August 28, 2026 09:14
AKnassa added a commit to AKnassa/astryx that referenced this pull request Sep 26, 2026
No textual conflicts. Calendar.tsx, Calendar.test.tsx, Calendar.doc.mjs
and styles.ts auto-merged cleanly alongside upstream's Calendar work
(meta#5306 min/max opening month, meta#5453 320px reflow, meta#5120/meta#5303 locale,
meta#6121 theme selectors).

Merge fallout fixed here:

- astracat F4: meta#6121 moved generated variant selectors from bare
  classes to data attributes, so the calendar-picker defineTheme
  assertion now expects `.astryx-calendar-picker[data-picker="year"]`
  instead of the stale `.astryx-calendar-picker.year`, matching how
  meta#6121 updated the sibling calendar-nav assertion. Red before: "expected
  ... to contain '.astryx-calendar-picker.year'" (Calendar.test.tsx:1885).

- Provider locale: meta#5120/meta#5303 moved the static caption onto the
  InternationalizationProvider locale and added the
  @astryx/no-raw-intl-locale lint rule, which the picker option labels
  (still undefined-locale) now fail. They pass `locale` like the caption
  again, so the two caption modes keep agreeing on month names. New test
  "labels the month picker in the provider locale, like the static
  caption" was red first (es-ES rendered "March", expected "marzo").

Calendar.test.tsx 112/112 green after both.

This branch was successfully deployed

1 active deployment
Preview — a3ab868f Deployed Aug 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants