Bug 187519
| Summary: | Date constructor with negative value argument | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | gfablima |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | ashvayka, isol2, msaboff |
| Priority: | P2 | ||
| Version: | Safari 11 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
gfablima
Hi everyone,
I found an inconsistence on Date() with a negative value.
I was looking on ES6 specification about this issue but I didn't found an answer, maybe the correct way is convert the -0 to +0
as V8 and SpiderMonkey do.
Steps to reproduce:
```
d = new Date(-0);
print(Object.is(d.getTime(), +0))
```
Actual results:
false
Expected results:
true
V8 and SpiderMonkey works as expected.
OS: Ubuntu 16.04 x64
Version: 606.1.9.4
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
isol2
Daily build v233772 not reproduce this issue
Alexey Shvayka
(In reply to isol2 from comment #1)
> Daily build v233772 not reproduce this issue
r261927 doesn't reproduce this either.
(In reply to gfablima from comment #0)
> I was looking on ES6 specification about this issue but I didn't found an
> answer, maybe the correct way is convert the -0 to +0
> as V8 and SpiderMonkey do.
Date constructor (https://tc39.es/ecma262/#sec-date-value) performs TimeClip at step 4.d,
which uses ToInteger (https://tc39.es/ecma262/#sec-tointeger) to normalize -0 to 0 (step 2).
This is covered by:
https://test262.report/browse/built-ins/Date/TimeClip_negative_zero.js
https://test262.report/browse/built-ins/Date/prototype/getTime/this-value-valid-date.js
https://test262.report/browse/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js
(all passed by JSC)