Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up20.3.3.2 Date.parse does not explicitly state out-of-range time values return NaN #1145
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
apaprocki
Mar 21, 2018
Contributor
Apparently the Safari implementation is accepting any year value from MIN_INT to MAX_INT - 1:
> Date.parse("-2147483648-01-01T00:00:00.000Z")
< NaN
> Date.parse("-2147483647-01-01T00:00:00.000Z")
< -67768100536348800000
...
> Date.parse("2147483646-01-01T00:00:00.000Z")
< 67767976170460800000
> Date.parse("2147483647-01-01T00:00:00.000Z")
< NaN
|
Apparently the Safari implementation is accepting any year value from
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Mar 21, 2018
Contributor
Implementation-defined semantics seem to be allowed for out-of-bounds values.
https://tc39.github.io/ecma262/#sec-date-time-string-format
Illegal values (out-of-bounds as well as syntax errors) in a format string means that the format string is not a valid instance of this format.
https://tc39.github.io/ecma262/#sec-date.parse
The function first attempts to parse the format of the String according to the rules (including extended years) called out in Date Time String Format (20.3.1.15). If the String does not conform to that format the function may fall back to any implementation-specific heuristics or implementation-specific date formats.
|
Implementation-defined semantics seem to be allowed for out-of-bounds values. https://tc39.github.io/ecma262/#sec-date-time-string-format
https://tc39.github.io/ecma262/#sec-date.parse
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
apaprocki
Mar 21, 2018
Contributor
To me, the purpose of that text is to allow implementations to have other overall different formats that implementations could support.
The strongest argument to me is that Date.parse() is defined to return:
parse interprets the resulting String as a date and time; it returns a Number, the UTC time value corresponding to the date and time.
and time value is defined to be -8,640,000,000,000,000 to 8,640,000,000,000,000.
It reads to me that implementations, while still allowing their own implementation-specific behavior, are still bound by returning a time value within the maximum range.
|
To me, the purpose of that text is to allow implementations to have other overall different formats that implementations could support. The strongest argument to me is that
and time value is defined to be -8,640,000,000,000,000 to 8,640,000,000,000,000. It reads to me that implementations, while still allowing their own implementation-specific behavior, are still bound by returning a time value within the maximum range. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Mar 21, 2018
Contributor
It reads to me that implementations, while still allowing their own implementation-specific behavior, are still bound by returning a time value within the maximum range.
Agreed.
Agreed. |
apaprocki
referenced this issue
Mar 22, 2018
Merged
Date.parse breathing test, time value maximum range test #1501
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Apr 4, 2018
Member
Seems to me like just a tiny bit more more clarifying text in the "Extended Years" plus the test262 tests you wrote should be sufficient to reinforce this interpretation. (Maybe you were already thinking along those lines.)
|
Seems to me like just a tiny bit more more clarifying text in the "Extended Years" plus the test262 tests you wrote should be sufficient to reinforce this interpretation. (Maybe you were already thinking along those lines.) |
apaprocki
referenced this issue
Apr 4, 2018
Merged
Normative: Cleanup Time Values and Time Range #1144
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Should this be closed, now that #1144 is merged? |
apaprocki commentedMar 21, 2018
•
edited
Section 20.3.3.2 currently states:
A time value is spec'd to only be the range -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds since UTC epoch, inclusive.
Issue:
Firefox properly (IMO) returns
NaNfor values outside of the specified time value range:Chrome allows any extended years value, even if the returned value loses precision due to
Numbernot being able to represent it exactly:Safari has almost the same behavior as Chrome, returning
Numbervalues that exceed the maximum time value range, but it loses precision in a different manner for the last value used above. More troubling, Safari seems to accept extended years > 6 digits, while Firefox and Chrome do not.Resolution:
NaN?