ecma402
ecma402 copied to clipboard
Normative: Read date-time options only once when creating DateTimeFormat objects
The first two commits are purely editorial and only move some things around, so it's easier to review the third commit, which contains the actual change.
Fixes #237 Fixes #706
TG2 discussion: https://github.com/tc39/ecma402/blob/master/meetings/notes-2022-10-06.md#normative-read-date-time-options-only-once-when-creating-datetimeformat-objects
Conclusion: Review the Test262 impact. Further discussion is not necessary in this group unless red flags show up. Approved with that condition.
@gibson042 any updates?
Please also note the changes going in a similar direction in Temporal. (I don't have the time right now to review if any changes would be helpful here or there.)
Conclusion: Review the Test262 impact.
Test262 PR created at https://github.com/tc39/test262/pull/3768.
Please also note the changes going in a similar direction in Temporal. (I don't have the time right now to review if any changes would be helpful here or there.)
I filed https://github.com/tc39/proposal-temporal/issues/2473 to adapt to this change on the Temporal side.
I confirmed with engine262 that the test changes at https://github.com/tc39/test262/pull/3768 are the correct updates for this PR: https://github.com/engine262/engine262/compare/3248ccc6793a4de3ca6cab1d3a16a113ddc8d0c9...gibson042:ecma402-gh-709-initializedatetimeformat
And since test changes are required, it's worth looking critically at the new read order proposed here [spoiler—I think slight modification is warranted]:
- localeMatcher [affects locale resolution, common to all service constructors]
- calendar [affects locale resolution]
- numberingSystem [affects locale resolution]
- hour12 [affects locale resolution]
- hourCycle [affects locale resolution]
- timeZone [e.g., "America/New_York"]
- component-specific configuration
- weekday
- era
- year
- month
- day
- dayPeriod
- hour
- minute
- second
- fractionalSecondDigits
- timeZoneName
- formatMatcher ["basic" vs. "best fit" output pattern selection hint]
- dateStyle [date-specific output pattern override]
- timeStyle [time-specific output pattern override]
Cross-facility comparison:
- DisplayNames reads localeMatcher, style ["narrow", "short", "long"], type ["language", "region", etc.], and then narrow configuration.
- ListFormat reads localeMatcher, type ["conjunction", "disjunction", "unit"], style ["long", "short", "narrow"].
- NumberFormat reads localeMatcher, numberingSystem, style ["decimal", "currency", "unit", etc.—analogous to type in other facilities], style detail fields, and then a hodgepodge of other configuration (notation, compactDisplay ["short", "long"—somewhat similar to style in other facilities], comma and sign control, etc.).
- RelativeTimeFormat reads localeMatcher, numberingSystem, style ["long", "short", "narrow"], and then configuration detail.
Considering the above, I think it does make sense to read calendar and numberingSystem where they are. formatMatcher and {date,time}Style form a style/type-like group that should probably precede reading component-specific fields, better aligning with DisplayNames and NumberFormat and RelativeTimeFormat. That leaves timeZone, which acts as input data augmentation and doesn't really have a great analogue in other facilities—I think it can make sense either immediately before or immediately after the aforementioned style group. I'm inclined to say "before", making the overall pattern "locale" then "context" then "style/type" then "details".
Concretely, I propose the narrow change here of moving the formatMatcher/dateStyle/timeStyle block immediately before the components-table loop and also reordering it to dateStyle then timeStyle then formatMatcher (since formatMatcher is subordinate to the other fields, only having an effect when they are both undefined).
EDIT: But I'm also fine with not reordering, since it may not survive #747 anyway.
EDIT: But I'm also fine with not reordering, since it may not survive #747 anyway.
Yeah, let's do any additional reordering as part of #747. That way this PR is restricted to fix the TOCTU issue described in #237.
@ryzokuken I think everything is ready to land this change. It's not necessary to have this for the 2023 release, but I'd like to see this landed soon-ish, because it should help to reduce the Intl.DateTimeFormat changes for Temporal.
@anba I understand, I missed that Richard had finished the review above. Two final things: this needs a rebase and did we get consensus from both TG1 and TG2?
TG2 approved unless test262 changes show a major impact. From Oct 06 2022 meeting notes:
Review the Test262 impact. Further discussion is not necessary in this group unless red flags show up. Approved with conditions.
this needs a rebase and did we get consensus from both TG1 and TG2?
Rebase is done. I don't think this was presented to TG1, at least I didn't see any references to this PR in the published notes.
@anba I went through the over a year's worth of editors' updates and couldn't find this PR in any, so there's a very high chance this was never presented to plenary. I'll do so at the next meeting.
TG2 agreement: https://github.com/tc39/ecma402/blob/master/meetings/notes-2023-04-06.md#normative-read-date-time-options-only-once-when-creating-datetimeformat-objects-709
Hi @ryzokuken, I don't see this issue being discussed at the May meeting. Do you plan to present it at the July meeting?
Thanks, André
Hi @anba! I indeed missed the fact that there's consensus here. I'll present it in the July meeting.
This got approval at TG1, merging after merge conflict is fixed.
The following tests in test262 need to be updated to match this PR
'intl402/DateTimeFormat/constructor-options-order-dayPeriod': [FAIL], 'intl402/DateTimeFormat/constructor-options-order': [FAIL], 'intl402/DateTimeFormat/constructor-options-order-fractionalSecondDigits': [FAIL], 'intl402/DateTimeFormat/constructor-options-order-timedate-style': [FAIL],
Fix tests in https://github.com/tc39/test262/pull/3879
The following tests in test262 need to be updated to match this PR
The test updates are in https://github.com/tc39/test262/pull/3768.
please rebase, resolve conflict and merge. Thanks
@ryzokuken - why is there a merge commit in this PR?
@justingrant because I tried giving the GitHub interface a chance :/ Will rebase manually next time.
@ryzokuken for future reference, there's an arrow next to "update branch" that lets you select "rebase branch", and it should work fine from the UI.
After a lot of confusion, I realized that part of my troubles fixing up the merge issues was that the commits were already in the main branch? https://github.com/tc39/ecma402/commit/02bd03a6ada4377c0bf414d65016a37defc7bd1b. Closing the PR, phew.