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

Problem with nanosecond parsing in ParseTemporalTimeZoneString #1795

Closed
FrankYFTang opened this issue Sep 2, 2021 · 2 comments · Fixed by #1796 or #1830
Closed

Problem with nanosecond parsing in ParseTemporalTimeZoneString #1795

FrankYFTang opened this issue Sep 2, 2021 · 2 comments · Fixed by #1796 or #1830

Comments

@FrankYFTang
Copy link
Contributor

In 13.44 ParseTemporalTimeZoneString ( isoString )
https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimezonestring

  1. Let z, sign, hours, minutes, seconds, fraction and name be the parts of isoString produced respectively by the UTCDesignator, TimeZoneUTCOffsetSign, TimeZoneUTCOffsetHour, TimeZoneUTCOffsetMinute, TimeZoneUTCOffsetSecond, TimeZoneUTCOffsetFraction, and TimeZoneIANAName productions, or undefined if not present.

noitce the definition of TimeZoneUTCOffsetFraction is

TimeZoneUTCOffsetFraction: Fraction
Fraction: DecimalSeparator TimeFractionalPart
TimeFractionalPart: Digit Digitopt Digitopt Digitopt Digitopt Digitopt Digitopt Digitopt Digitopt
DecimalSeparator:  one of . ,

Notice TimeZoneUTCOffsetFraction is defined as Fraction, which include DecimalSeparator before TimeFractionalPart

Therefore, if we have a string valid in the syntax of TemporalTimeZoneString as below:
"+23:34:56.987654321"
then TimeZoneUTCOffsetFraction is ".987654321" NOT "987654321"
so step 2 will set fraction to ".987654321"

Then in 6-g

6-g If fraction is not undefined, then
i. Set fraction to the string-concatenation of the previous value of fraction and the string "000000000".
ii. Let nanoseconds be the String value equal to the substring of fraction from 0 to 9.
iii. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds).

6-g-i set fraction to ".987654321000000000"
6-g-ii set nanoseconds to ".98765432"
6-g-iii set nanoseconds to "0"

Also related to another issue I just reported in #1794

@Ms2ger @ljharb @ptomato @justingrant @ryzokuken

@FrankYFTang
Copy link
Contributor Author

Same problem also in
11.6.8 ParseTimeZoneOffsetString ( offsetString )
https://tc39.es/proposal-temporal/#sec-temporal-parsetimezoneoffsetstring

3. Let sign, hours, minutes, seconds, and fraction be the parts of offsetString produced respectively by the TimeZoneUTCOffsetSign, TimeZoneUTCOffsetHour, TimeZoneUTCOffsetMinute, TimeZoneUTCOffsetSecond, and TimeZoneUTCOffsetFraction productions, or undefined if not present.

and therefore fraction is TimeZoneUTCOffsetFraction production

Then in step 10

10. If fraction is not undefined, then
a. Set fraction to the string-concatenation of the previous value of fraction and the string "000000000".
b. Let nanoseconds be the String value equal to the substring of fraction consisting of the code units with indices 0 (inclusive) through 9 (exclusive).
c. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds)

so nanoseconds will ALWAYS be 0 in this current algorithm.

(hum... maybe that is what I LIKE to see- let the TimeZone offset never be able to set to sub second precision....) I am perfectly fine if we do NOT fix this issue because that is rexactly I hope the champion would agree. Somehow to spec text passing Stage 3 already did that for me :)

@sffc

@FrankYFTang
Copy link
Contributor Author

Should we fix this by
changing

6-g-ii. Let nanoseconds be the String value equal to the substring of fraction from 0 to 9.

to

6-g-ii. Let nanoseconds be the String value equal to the substring of fraction from 1 to 10.

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