-
Notifications
You must be signed in to change notification settings - Fork 11
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
Locale with -u-fw- value other than 13 value will cause assertion #78
Comments
this is a difficult issue. What should we do in this case? |
@sffc @zbraniecki @littledan @anba need advise |
Hmm, another edge case. This is a consequence of our departure from how other subtags work based on the feedback from TG1 that we should return integers rather than strings. Current behavior of invalid values in other subtags: // OK: gregory1 is not a real calendar but it is BCP-47
new Intl.Locale("en", { calendar: "gregory1" }).toString()
'en-u-ca-gregory1'
// Wrong: gregory12 is too long for BCP-47
new Intl.Locale("en", { calendar: "gregory12" }).toString()
// Uncaught RangeError: Incorrect locale information provided The following cases should always be RangeError since they are BCP-47:
So, the cases we need to work out are:
For each of these cases, we need to decide:
Some options:
I don't see a reason for cases 1 and 2 to differ in behavior. |
|
agree |
TG2 discussion: https://github.com/tc39/ecma402/blob/master/meetings/notes-2023-10-12.md#locale-with--u-fw--value-other-than-13-value-will-cause-assertion Conclusion: We already have a getter for the integers in |
I sent a private email to @littledan to explain why we like to change Intl.Locale.prototype.firstDayOfWeek to reuturn string or undefined from number or undefined. And how Intl.Locale.prototype.getWeekInfo().firstDay already address the use case he has in mind and will not be impacted by this. |
I don't want to cause you all to spend too much more time on this. Although my intuition was option 1, this isn't something that I am going to insist on. I just don't see the argument for why this API should be lenient, given that from a developer's perspective, they have to expect it to throw. As a non-expert in this area, I would've expected that Nevertheless, I see that the current API is consistently lenient in exactly this way: e.g., you can get |
Dear @littledan : I think we need to look at this as two layers of functionality of the API For the API in layer 2- number is for sure what is best- and that is address in getWeekInfo().firstDay See https://en.wikipedia.org/wiki/French_Republican_calendar#Ten_days_of_the_week I do not think there is a strong case to support such calendar right now and I do not believe CLDR has any plan to support that. But just an example to show you in the history there are people prefer a week is not 7 days. |
Yes, I accept that this API has those two layers. I don’t think this separation does an ideal job serving its users, but it is possible to work through given the existence of the other layer. So it is OK to proceed as you proposed, from my perspective. |
So... I plan to change the spec to I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun">> |
Propose fix in #79 |
sorry, this is not right. I need to rework on this. Intl.Locale.prototype.firstDayOfWeek need to return string, but not just that 7 string values. |
This issue is addressed in #79 |
This is reported by @trflynn89 in #70 (comment)
Copy over here
"Hello - I'm implementing this change over in Serenity's LibJS and had a question. Do the AO definitions of WeekdayToNumber and WeekdayToString seem backwards? Currently WeekdayToNumber returns a string, and WeekdayToString returns a number, which seems pretty confusing to me."
"
It also seems like it's possible to hit the Assert: Should not reach here. step in WeekdayToNumber if we provide an invalid value as a -u-fw extension.
For example, if the user provides en-u-fw-100, then in step 34 of Intl.Locale:
Then r.[[fw]] will have a value of 100. We will pass that to WeekdayToNumber and fail that assertion.
"
The text was updated successfully, but these errors were encountered: