-
Notifications
You must be signed in to change notification settings - Fork 106
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: Updates on fractionalSecondDigits in preparation for Temporal #715
Conversation
5373e8c
to
9b4ac3c
Compare
cc @FrankYFTang |
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.
Hi, I'm not an ECMA-402 reviewer but I had some questions from reviewing the test262 tests for this change.
@@ -736,7 +737,7 @@ <h1>Abstract Operations for DateTimeFormat Objects</h1> | |||
<tr> | |||
<td>[[FractionalSecondDigits]]</td> | |||
<td>*"fractionalSecondDigits"*</td> | |||
<td>*1*<sub>𝔽</sub>, *2*<sub>𝔽</sub>, *3*<sub>𝔽</sub></td> | |||
<td>*1*<sub>𝔽</sub>, *2*<sub>𝔽</sub>, *3*<sub>𝔽</sub>, *4*<sub>𝔽</sub>, *5*<sub>𝔽</sub>, *6*<sub>𝔽</sub>, *7*<sub>𝔽</sub>, *8*<sub>𝔽</sub>, *9*<sub>𝔽</sub></td> |
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.
There seems to be a pre-existing inconsistency in ECMA-402 about whether [[FractionalSecondDigits]] contains Number or mathematical values. Properties of Intl.DateTimeFormat instances says either undefined or a "positive non-zero integer Number value" but step 36.d of InitializeDateTimeFormat stores a mathematical value (returned from GetNumberOption in step 36.b.i) in the slot.
In any case I'm not sure if it's necessary to amend this table, since a value > 3 passed for this option is converted to undefined. The other place where it could be used is for the info in the [[LocaleData]].[[<locale>]].[[formats]].[[<calendar>]] internal slots, in which it might be better to say "a positive non-zero integer" as well.
I bring this up from a test262 perspective, because I'm not sure whether the values in this cell of the table are observable in that they need to be tested in test262.
CC @FrankYFTang who voiced concerns. |
As an action point from past TG2 Meeting #715 : @sffc @FrankYFTang @ryzokuken any thoughts about the next steps? |
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.
@ptomato's comment doesn't block this PR from landing, all green from my side!
Perhaps we could file that as a separate issue on this repo and discuss it in isolation? |
→ #725 |
@romulocintra any update? |
Hi @ryzokuken, I split this into two different parts:
and this current PR :
|
^ @sffc |
I am very concerned about this PR and oppose this getting merged into ECMA402 as a ECMA402 PR. Instead, I propose these changes be merged into the Temporal proposal. One thing I would like to point out clearly, according to TG2 meeting notes, we never discussed the details during the meeting. In both meeting, I was always direct to “ to discuss offline “ So here I am, discuss it offline with you. We need to discuss this PR with two different issues: First of all, in the current shape of this PR, we change 3 different places of in ECMA402 For dealing with 0, the current shape of ECMA402 disallows 0. And from what I read in #590 there are two only reasons mentioned: Now, let’s talk about 4-9. The change by itself, from my point of view, is not only unnecessary, but very confusing in this stage and should not be landed into ECMA402:
Prior to this PR, we got true here. With this PR, it still get true. But now consider the following
without this PR, the new will simply throw RangeError because 4 is not an acceptable value but with this PR, the new will success and y will be set to undefined. But.... what will be the df format? and this is very confusing because the 4 didn't through, neither get honor in the format, it was just be treated as undefined. |
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.
I strongly object this PR
now, you will say, Temporal need to support fractionalSecondDigits 0, and 4-9 so we need to change, it. ok where are that stated in Temporal spec now? Let's see, the word "fractionalSecondDigits" currently appeared 26 times inside It appear twice in ToSecondsStringPrecision and that function impact the following functions:
Now, according to the Temporal spec which passed Stage 3 (and the current shape of the spec text), the fractionalSecondDigits is only needed to support 1-3 for toLocaleString and Intl.DateTimeFormat (see step 36-b-i in https://tc39.es/proposal-temporal/#sec-temporal-initializedatetimeformat ) . That is what have already reach consense. There were no consense reached to support toLocaleString or Intl.DateTimeFormat beyond 3 to reach nanosecond precision. If we follow the Temporal spec text which reach Stage 3 (and what is on the spec today) we would throw RangeError with the following code:
which is the spec we all agreed in TC39 to support so far when it get Stage 3 advacement. I never oppose the Temporal reach Stage 3 because it only require 3 fractionalSecondDigits but not beyond it. If the spec text require more than 3 I would block it when it asked to advance to Stage 3. But since the champion didn't I didn't block. But... why I would block? The reason is simple. We will have implementation difficult to support sub millisecond precision for these toLocaleString or Intl.DateTimeFormat.prototype.format . Currently, we are depending on ICU to do the format, but ICU cannot handle nanosecond precision yet. (at least not in 72.1) |
Let me illusrate the difficulty of supporting nanosecond precision in Temporal.*.prototype.toLocaleString and Intl.DateTimeFormat.prototype.format(|ToParts) Currently, all known browsers implement it by (either C API or C++ API) using ICU. Here is the ICU documentation: notice the text Now, with the followng patch for v8, I can implement a BUGGY attempt to support Temporal to nanosecond precision, but this is only BUGGY attempt which prove the point it cannot be done with the current ICU API:
The shortcoming is in two issues not just one
Let me illustrate the issue with the following call (this is run on my local machine after I apply the patch above:
Now, the fact it show show the ICU API limitation mentioned in the API doc
This show, my code did get the bigint as Therefore, even if we fix the ICU SimpleDateFormat:format to format the rest of 6 digits from the double instead of "Appends zeros if more than 3 letters specified" , it will generate incorrect result, likely for the value fractionalSecondDigits> 5 |
In summary, if we want to change ICU to support the formatting of nanosecond precision, not only it need to change the internal implementation of SimpleDateFomrat::format, it also need to add new API to take a new data type to encode the value which has nanosecond precision, which currently does not exist in ICU. Accepting an behavior of 1 to 6 '0' as the format result in place with the real didigt stored in the Temporal object is a very very bad one because for anyone whe care about setting the fractionalSecondDigits > 3, we have to assume the information below millisecond is important enough for them to use such setting, and truncating it to millisecond then adding 0 will misguide the reader as a different value than what it actually is and could cause diaster for any application which care about sub millisecond precision. The users would either
and supporting an API which could set it to higher precision but allow the formatted output in lower precision (incorrect value in that precision, actually) is very dangerous. and I would argue no body in the world will need such hehavior. |
The requirement for ICU to support date time format for nanosecond precsion is filed under https://unicode-org.atlassian.net/browse/ICU-22218 |
The current Temporal proposal spec text only require 1 - 3 step 36-b-3
|
Conclusion: Put this issue on the backlog, but pursue the ICU issue in parallel. Revisit after Temporal is merged. |
Closes #590
Update 402 to :
0
to mean the same as undefined0