Bug 185868 - Date.parse() doesn't properly handle input outside of ES Spec limits
Summary: Date.parse() doesn't properly handle input outside of ES Spec limits
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-22 07:50 PDT by Michael Saboff
Modified: 2018-05-23 13:03 PDT (History)
7 users (show)

See Also:


Attachments
Patch (7.29 KB, patch)
2018-05-23 12:00 PDT, Michael Saboff
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2018-05-22 07:50:36 PDT
From May 2018 TC-39 meeting:

SpiderMonkey strictly conforms to the Time Value specification:
> Date.parse("-271821-04-19T11:59:59.999Z")
NaN
V8, JSC:
> Date.parse("-271821-04-19T11:59:59.999Z")
-8640000043200001

> Date.parse("-999999-01-01T00:00:00.000Z")
V8/JSC	-31619087596800000
> Date.parse("-999999-01-01T00:00:00.001Z")
V8/JSC	-31619087596800000
> Date.parse("-999999-01-01T00:00:00.002Z")
V8		-31619087596800000
JSC		-31619087596799996

> Date.parse("-1000000-01-01T00:00:00.000Z")
V8		NaN
> Date.parse("-1000000-01-01T00:00:00.000Z")
JSC		-31619119219200000

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

Test262 tests will land soon.
Comment 1 Michael Saboff 2018-05-23 12:00:17 PDT
Created attachment 341111 [details]
Patch
Comment 2 Mark Lam 2018-05-23 12:07:02 PDT
Comment on attachment 341111 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=341111&action=review

r=me

> Source/WTF/wtf/DateMath.cpp:562
> +    // Clamp to EcmaScript standard of +/- 100,000,000 days from 01 January, 1970.

Let's add a link to https://tc39.github.io/ecma262/#sec-time-values-and-time-range here.
Comment 3 Michael Saboff 2018-05-23 13:02:41 PDT
Committed r232122: <https://trac.webkit.org/changeset/232122>
Comment 4 Radar WebKit Bug Importer 2018-05-23 13:03:33 PDT
<rdar://problem/40495678>