Skip to content
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

Add support for -u-fw and other Unicode extensions that could impact the result #68

Closed
sffc opened this issue May 2, 2023 · 13 comments
Closed

Comments

@sffc
Copy link
Contributor

sffc commented May 2, 2023

Related: #30, tc39/ecma402#580

If I write

new Intl.Locale("en-u-fw-tue").getWeekInfo()

then I should get that the first day is Tuesday, but it currently ignores the -u-fw.

@FrankYFTang
Copy link
Collaborator

This issue, if put into the proposal, would mean we also have to

  1. add additional getter "get Intl.Locale.prototype.firstDayOfWeek"
  2. in https://tc39.es/ecma402/#sec-intl.locale-internal-slots add "fw" into "The value of the [[RelevantExtensionKeys]]"
  3. in Intl.Locale ( tag [ , options ] ) we need to add step to read "firstDayOfWeek" from option and validate the value.

@sffc
Copy link
Contributor Author

sffc commented May 4, 2023

@anba
Copy link
Contributor

anba commented May 17, 2023

If I write

new Intl.Locale("en-u-fw-tue").getWeekInfo()

then I should get that the first day is Tuesday, but it currently ignores the -u-fw.

IIRC you actually get Tuesday starting with ICU 73 (ICU-22226), assuming the input locale is passed as-is to ICU. Addressing #30 should help to clarify how Unicode extension tags are handled.

@FrankYFTang
Copy link
Collaborator

So I will add a new getter

1.4.X get Intl.Locale.prototype.firstDayOfWeek

that will return one of the 7 possible values
"sun", "mon", "tue", "wed", "thu", "fri", "sat"

@FrankYFTang
Copy link
Collaborator

I think this request surface yet another problem in our current spec
Currently the return value of
Intl.Locale.prototype.getWeekInfo ( )
use integer 1-7 to represent the weekday as specified in
https://tc39.es/proposal-intl-locale-info/#sec-week-info-of-locale

in the firstDay field as a single value and in the weekend as an array (usually 2 values)

But since we are now need to add a getter firstDayOfWeek to return string <<"sun", "mon", "tue", "wed", "thu", "fri", "sat">>
should we also change the getWeekInfo().firstDay to reutrn one of <<"sun", "mon", "tue", "wed", "thu", "fri", "sat">>
and getWeekInfo().weekend to return an arry of string in <<"sun", "mon", "tue", "wed", "thu", "fri", "sat">> instead?

@sffc
Copy link
Contributor Author

sffc commented Jun 30, 2023

@FrankYFTang
Copy link
Collaborator

This issue and #70 was presented to TC39 in July 12, 2023 meeting and does NOT reach consensus for the proposed changes.

Here are my understanding of the part which reach consensus:
a. No objection of the need to add "fw" to the [[RelevantExtensionKeys]] internal slots in Intl.Locale in order to read "-u-fw-" from the locale identifier.
b. No objection of adding the [[FirstDayOfWeek]] to internal slots in Intl.Locale to keep track the information from a.
c. No objection that the getWeekInfo().firstDay will depends on the value in the [[FirstDayOfWeek]] to internal slots in Intl.Locale
d. No objection to keep the getWeekInfo().firstDay value in the range 1..7 to sync with Temporal.
e. No objection of the need to add a option reading step to get the information to [[FirstDayOfWeek]] in addition to the parsed result from a.
e. No objection of the property name to be read from the option as "firstDayOfWeek".
f. No objection of adding a getter Intl.Locale.prototype.firstDayOfWeek .

But there are disagreement during July 12 TC39 about
I. What should be the possible values that Intl.Locale.prototype.firstDayOfWeek could return.
II What should be the possible values that the option reading of firstDayOfWeek proper should accept.

Option A (as in the current state (July 11, 2023) of PR70)

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun">>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun">> Default: undefined

Option B (as mentioned in the TC39)

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, 1, 2, 3, 4, 5, 6, 7>>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun", 1, 2, 3, 4, 5, 6, 7>> Default: undefined

Option C (Also mentioned in the TC39)

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, 1, 2, 3, 4, 5, 6, 7>>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun", 0, 1, 2, 3, 4, 5, 6, 7>> Default: undefined
where 0, 7, "sun" all repesent Sunday in option reading

Option D

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, 1, 2, 3, 4, 5, 6, 7>>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, 1, 2, 3, 4, 5, 6, 7>> Default: undefined

Option E

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, 1, 2, 3, 4, 5, 6, 7>>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, 0, 1, 2, 3, 4, 5, 6, 7>> Default: undefined
where 0, and 7 both repesent Sunday in option reading

Option C and Option E consider the fact that Date.prototype.getDay ( ) return 0, but not 7, for Sunday.
See https://tc39.es/ecma262/#sec-date.prototype.getday

@FrankYFTang
Copy link
Collaborator

Most people after TG2 2023-09-07 meeting unofficially support Option C

@FrankYFTang
Copy link
Collaborator

FrankYFTang commented Nov 16, 2023

This issue is addressed by PR70 after TC39 on 2023-09 which is option C. However, it cause issue in #78 and we now plan to revert from option C

I plan to change the spect to the following:
I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun">>
2. {firstDayOfWeek} for new Intl.Locale() accepts: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun", "0", "1", "2", "3", "4", "5", "6", "7">> Default: undefined
where "0", "7", "sun" all repesent Sunday in option reading

@FrankYFTang
Copy link
Collaborator

Propose fix in #79

@FrankYFTang
Copy link
Collaborator

I. Intl.Locale.prototype.firstDayOfWeek returns: <<undefined, "mon", "tue", "wed", "thu", "fri", "sat", "sun">>

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.

@FrankYFTang
Copy link
Collaborator

#79 and #82 together should address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants