Problem
Intl.DateTimeFormat currently preserves only the user-provided dayPeriod option. It does not retain the dayPeriod field selected by the locale date-time pattern.
The current engine result for:
new Intl.DateTimeFormat("en-US", {
timeZone: "UTC",
hour: "numeric",
hourCycle: "h11"
}).resolvedOptions()has keys:
locale,calendar,numberingSystem,timeZone,hourCycle,hour12,hourSystem JavaScriptCore selects the 12-hour pattern and returns:
locale,calendar,numberingSystem,timeZone,hourCycle,hour12,dayPeriod,hourwith dayPeriod: "short". The same distinction holds for h12 versus h23/h24 in the audited en-US matrix.
ECMA-402 DateTime Format Records require the selected record to have [[dayPeriod]] when its pattern contains {dayPeriod}; DateTimeFormat resolvedOptions then projects that field in table order.
The source cause is structural: dtfProcessOptionsKind records only the requested component strings, and dtfStoreOptions publishes resolved_day_period directly from that request. No exact selected-pattern record projects pattern-added fields into immutable native state.
Scope
Model the selected BasicFormatMatcher/BestFitFormatMatcher result as exact native formatter state, including pattern-added fields and widths. The selected record must drive both formatting and reflection.
This must not be implemented by:
- hardcoding
en, h11, or h12 behavior; - assuming every 12-hour pattern has the same day-period width;
- adding
dayPeriodonly insideresolvedOptions(); - changing only key order or manufacturing a property without formatter state;
- hiding an engine-specific normalization in the benchmark;
- retaining movable JavaScript strings or ordinary hidden properties as native state.
Acceptance criteria
- A benchmark-first differential row freezes h11/h12/h23/h24, locale-extension resolution,
hour12precedence, exact key order, day-period width, omission, fresh-result identity, and complete checksums before runtime changes. - The selected native DateTime Format Record retains every pattern field required by ECMA-402, including pattern-added
dayPeriod, with a closed enum/static-cell representation where the value set is closed. resolvedOptions()matches system JSC for representative 12-hour and 24-hour locales, explicit component/basic and best-fit matching, style patterns,hourCycle/locale-extension/hour12precedence, and no-hour omission.format,formatToParts,formatRange, andformatRangeToPartsconsume the same selected record, so reflection cannot diverge from emitted parts.- Constructor observation order, OOM/fault injection, precise and moving GC, no-GIL/TSan publication, and formatter reclamation remain exact.
- Focused units, exact Intl.DateTimeFormat Test262 accounting, full units, and benchmark differential/checksum validation pass with quantified before → after results.
Relationship
Discovered while freezing #772. The #772 hour-cycle enum/allocation change remains a separate performance boundary; its benchmark must expose this checksum divergence and link this issue rather than normalizing it away.