-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Date.UTC(x) [single-argument case] semantics update #1665
Comments
I think it's the reverse isn't it? Date.UTC() currently returns Date.UTC(0, 0, ...) and should return NaN. Date.UTC(2017) currently returns the right thing. |
The patch I previously submitted made it so assert(isNaN(Date.UTC()), "expected: Date.UTC() is NaN");
assert(!isNaN(Date.UTC(2017)), "expected: Date.UTC(2017) is not NaN");
assert(!isNaN(Date.UTC(2017, 0)), "expected: Date.UTC(2017, 0) is not NaN;");
assert(!isNaN(Date.UTC(2017, 0, 1)), "expected: Date.UTC(2017, 0, 1) is not NaN;");
assert(isNaN(Date.UTC(2017, undefined)), "expected: Date.UTC(2017, undefined) is NaN");
assert(Date.UTC(2017) === Date.UTC(2017, 0), "expected: Date.UTC(2017) === Date.UTC(2017, 0)");
assert(Date.UTC(2017, 0) === Date.UTC(2017, 0, 1), "expected: Date.UTC(2017, 0) === Date.UTC(2017, 0, 1)"); Current behavior:
Expected behavior: |
Yes ok sorry. Seems good, thank you! |
. Fixes chakra-core#1665: Date.UTC(x) [one-argument] spec change.
…ime value Merge pull request #4615 from xiaoyinl:dateUTCoverflow According to spec [Section 20.3.3.4](https://tc39.github.io/ecma262/#sec-date.utc), if the time value is larger than `ktvMax` or smaller than `ktvMin`, then `Date.UTC` should return `NaN` rather than return the actual value. Also updated the link at L1645 to #1665: "Date.UTC(x) [single-argument case] semantics update". Test case: `Date.UTC(2001, 1, 5e+9)` ChakraCore: 432000980899200000 SpiderMonkey and v8: NaN
[MERGE #4615 @xiaoyinl] Date.UTC should return NaN for out-of-range time value Merge pull request #4615 from xiaoyinl:dateUTCoverflow According to spec [Section 20.3.3.4](https://tc39.github.io/ecma262/#sec-date.utc), if the time value is larger than `ktvMax` or smaller than `ktvMin`, then `Date.UTC` should return `NaN` rather than return the actual value. Also updated the link at L1645 to chakra-core/ChakraCore#1665: Reviewed-By: chakrabot <[email protected]>
Behavior implemented in #1333 is that
Date.UTC(x)
andDate.UTC()
wheretypeof x === number
returns NaN.Spec semantics will be updated (see tc39/ecma262#642) so that
Date.UTC()
returns NaN andDate.UTC(2017) === Date.UTC(2017, 0)
.See:
tc39/ecma262#642
#1318 (issue)
#1333 (PR)
/cc @bterlson
The text was updated successfully, but these errors were encountered: