-
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
Specify canonicalization algorithms for Intl enumeration #726
Comments
@ben-allen to sync with @ptomato and coordinate on a PR. |
Note that the time zones (unlike the other things that @gibson042 and I have been working on an editorial PR for 262 (tc39/ecma262#3035) to specify how time zone canonicalization works there. (With editorial PRs for 402 and Temporal to follow if the 262 PR is accepted.) The summary of the PR is:
I don't know if this approach is relevant to other things that BTW, here's a few reasons for the set of AOs above:
struct TimeZoneIdRecord {
const unsigned short idIndex; // could also be a 10-bit field
const unsigned short canonicalIdIndex; // could also be a 10-bit field
};
// Everything below populated via automated build step using IANA and/or CLDR data
const unsigned short TIMEZONE_ID_COUNT = 579;
const char* sortedTimeZoneIds[TIMEZONE_ID_COUNT] = {
"Africa/Abidjan",
"Africa/Accra",
// . . .
};
// for case-normalized comparisons
const char* lowerCaseTimeZoneIds[TIMEZONE_ID_COUNT] = {
"africa/abidjan",
"africa/accra",
// . . .
};
const TimeZoneIdRecord sortedTimeZoneIdMap[TIMEZONE_ID_COUNT] = {
{ 0, 0 }, // example of a canonical ID
{ 1, 1 },
// . . .
{ 203, 16 }, // example of a non-canonical ID
// . . .
}; |
AvailableCalendars should return all possible aliases, so that other places in the spec (e.g. in the future, validating a string calendar ID in Temporal) can use them to determine whether a given input value is valid. This input value can subsequently be canonicalized by another abstract operation, CanonicalizeCalendar. In Intl.supportedValuesOf(), on the other hand, we should not return all possible aliases, so we filter them out using CanonicalizeCalendar before returning the list of AvailableCalendars codes as an array to the caller. See tc39/proposal-intl-enumeration#49. This is the part of that PR that I consider relevant for the future integration of Temporal. The time zone parts were already done as part of tc39#876. If desired, I could implement the rest of that PR, adding CanonicalizeCollation, CanonicalizeCurrency, CanonicalizeNumberingSystem, and CanonicalizeUnit as well. Closes: tc39#726
AvailableCalendars should return all possible aliases, so that other places in the spec (e.g. in the future, validating a string calendar ID in Temporal) can use them to determine whether a given input value is valid. This input value can subsequently be canonicalized by another abstract operation, CanonicalizeUValue, which we can use in several other places. In Intl.supportedValuesOf(), on the other hand, we should not return all possible aliases, so we filter them out using CanonicalizeUValue before returning the list of AvailableCalendars codes as an array to the caller. See tc39/proposal-intl-enumeration#49. This is the part of that PR that I consider relevant for the future integration of Temporal. The time zone parts were already done as part of tc39#876. If desired, I could implement the rest of that PR, adding CanonicalizeCollation, CanonicalizeCurrency, CanonicalizeNumberingSystem, and CanonicalizeUnit as well. Closes: tc39#726
AvailableCalendars should return all possible aliases, so that other places in the spec (e.g. in the future, validating a string calendar ID in Temporal) can use them to determine whether a given input value is valid. This input value can subsequently be canonicalized by another abstract operation, CanonicalizeUValue, which we can use in several other places. In Intl.supportedValuesOf(), on the other hand, we should not return all possible aliases, so we filter them out using CanonicalizeUValue before returning the list of AvailableCalendars codes as an array to the caller. See tc39/proposal-intl-enumeration#49. This is the part of that PR that I consider relevant for the future integration of Temporal. The time zone parts were already done as part of tc39#876. If desired, I could implement the rest of that PR, additionally supporting collation, currency, numbering system, and unit canonicalization. Closes: tc39#726
#889) AvailableCalendars returns all supported values, including aliases (which will be needed for calendar ID validation in Temporal). Intl.supportedValuesOf("calendar"), however, continues to return only canonical values, internally filtering out aliases by using a new CanonicalizeUValue operation that also has applications elsewhere in the spec. Closes: #726
Once Intl.supportedValuesOf becomes part of the specification, apply the changes proposed in tc39/proposal-intl-enumeration#49
The text was updated successfully, but these errors were encountered: