-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: Change the hourCycle default logic #758
Conversation
While hour12 is either true or false, let hourCycle to be either 'h12' or 'h23' but not 'h11' nor 'h24'. The current logic is not reasonable. We see no region in the CLDR use h11 nor h24 hour cycle as default. While we set a hour12: true on a 24 hour system region (which use 0:00 - 23:59), we should set to h12 instead of h11 Do not perform the starnge logic of setting default hourCycle based on both hour12 and the defaultHourCycle while hour12 is true or false. Instead, only depends on hour12 to set it to h12 or h23. Address #402
notice grep "<hours.*allowed" ./cldr/common/supplemental/supplementalData.xml show possibility of h H or K but no possibility of k in the latest CLDR and it is unlikely that will happen in the future from my understanding. |
PTAL I took anba's suggestion and make it data driven. |
Co-authored-by: Shane F. Carr <[email protected]>
Co-authored-by: Shane F. Carr <[email protected]>
somehow no one ever present this PR to TG39 in May 2023 or July 2023 meeting. I add it to https://github.com/tc39/agendas/blob/main/2023/09.md |
we need test262 tests for this PR |
…hich now associates h12 with h23 rather than h24. see tc39/ecma402#758.
@anba - any suggetion how should we write test262 test to test this PR? |
https://github.com/tc39/test262/blob/main/test/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js needs to be updated to reflect the PR changes. The test is already marked as locale-specific, so we could simply change it to: let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi"];
for (let locale of locales) {
let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle;
assert(
hcDefault === "h11" || hcDefault === "h12" || hcDefault === "h23" || hcDefault === "h24",
"hcDefault is one of [h11, h12, h23, h24]"
);
let hour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
assert(hour12 === "h11" || hour12 === "h12", "hour12 is one of [h11, h12]");
let hour24 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle;
assert(hour24 === "h23" || hour24 === "h24", "hour24 is one of [h23, h24]");
if (hcDefault === "h11" || hcDefault === "h12") {
assert.sameValue(hour12, hcDefault, "hour12 matches hcDefault");
} else {
assert.sameValue(hour24, hcDefault, "hour24 matches hcDefault");
}
// 24-hour clock uses the "h23" format in all locales.
assert.sameValue(hour24, "h23");
// 12-hour clock uses the "h12" format in all locales except "ja".
assert.sameValue(hour12, locale === "ja" ? "h11" : "h12");
} |
@FrankYFTang @anba is merging this PR blocked on the tests? |
2023-09-26: This PR achieved TG1 consensus |
This PR reach consensus on 2023-09-26 meeting |
I believe the PR need to merge first before merging the test, right? |
The test is blocked by the merge of this PR tc39/test262#3885 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small issues in the description text, otherwise LGTM!
Co-authored-by: André Bargull <[email protected]>
Co-authored-by: André Bargull <[email protected]>
🎉 |
…hich now associates h12 with h23 rather than h24. see tc39/ecma402#758.
…hich now associates h12 with h23 rather than h24. see tc39/ecma402#758.
…hich now associates h12 with h23 rather than h24. see tc39/ecma402#758.
While hour12 is either true or false, let hourCycle to be either 'h12' or 'h23' but not 'h11' nor 'h24'. The current logic is not reasonable. We see no region in the CLDR use h11 nor h24 hour cycle as default. While we set a hour12: true on a 24 hour system region (which use 0:00 - 23:59), we should set to h12 instead of h11 Do not perform the starnge logic of setting default hourCycle based on both hour12 and the defaultHourCycle while hour12 is true or false. Instead, only depends on hour12 to set it to h12 or h23. Address tc39#402 Co-authored-by: Shane F. Carr <[email protected]> Co-authored-by: Ujjwal Sharma <[email protected]> Co-authored-by: André Bargull <[email protected]>
Can I assume that this will form part of a changeset for the 10th edition? Ref: https://ecma-international.org/publications-and-standards/standards/ecma-402/ |
Spec tc39/ecma402#758 Change the hourCycle for not returning h24 while hour12 is false Bug: v8:14542 Change-Id: I65a6719ed0da1fd43c3ac25bd107c89a25ae7f21 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5319663 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#92519}
…option (#33343) * Update `Intl.DateTimeFormat` to reflect new behaviour of `hourCycle` option after tc39/ecma402#758 * Update files/en-us/web/javascript/reference/global_objects/intl/datetimeformat/datetimeformat/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update index.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Joshua Chen <[email protected]>
While hour12 is false, let hourCycle to be alwasyt 'h23' but not 'h24'.
The current logic is not reasonable. We see no region in the CLDR use h24 hour cycle as default. While we set a hour12: false on a 12 hour system region (which use 1:00 - 12:59), we should set to h23 instead of h24
We need to make this change
so while hour12 is false on 'en' locale, it will be set to h23 instead of h24
but also while hour12 is true on 'ja' locale, it will be set to h11 but not h12.
Address #402