Bug 187519 - Date constructor with negative value argument
Summary: Date constructor with negative value argument
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 11
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-10 08:38 PDT by gfablima
Modified: 2020-05-20 14:47 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gfablima 2018-07-10 08:38:46 PDT
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
Comment 1 isol2 2018-07-12 11:33:00 PDT
Daily build v233772 not reproduce this issue
Comment 2 Alexey Shvayka 2020-05-20 14:47:22 PDT
(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)