New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 3 users

Issue metadata

Status: WorkingAsIntended
Owner:
Last visit > 30 days ago
Closed: Feb 2012
Cc:
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: FeatureRequest
ES5



Sign in to add a comment

Date.parse doesn't accept leap second

Reported by utatane....@gmail.com, Feb 12 2012

Issue description

In ECMA262 5.1 section 15.9.1.15, Date.parse should accept ISO-8601, and ISO-8601 defined 60 as second for leap second.

for example,

    new Date('1999-12-31T23:59:60.000').getTime() should be 946684800000

but current V8 date parser reject it.

JavaScriptCore accept leap second.
http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/DateMath.cpp?rev=104527#L722

And I attached patch including parser fix and test cases on mjsunit.

 
leap-second.patch
1.6 KB View Download
Above patch considers 60 over seconds.

for example,

  '1999-12-31T23:59:60.999'

in this case, second is 60.999. This is Java's behavior.

On the other hand, JSC clamp this to 60 second.
http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/wtf/DateMath.cpp?rev=104527#L725
in JSC way,

  Date.parse('1999-12-31T23:59:60.999') === Date.parse('1999-12-31T23:59:60.000')

So I attached another version patch, that clamp second over 60 to 60.

leap-second-2.patch
2.1 KB View Download
Owner: rossberg@chromium.org
Status: PendingFurtherInfo
The ECMA262 spec says "In time values leap seconds are ignored." without really saying what that implies (ignore their existence, returning NaN, or ignore their effect, returning the same time as the second that follows?).

What bothers me is that fake leap seconds are also accepted in this suggestion, such as '1999-12-31T22:55:60.999'. A quick test on the current releases of Firefox and Safari shows that both also return NaN.

Please understand that we do not want to introduce new behavior if not for compatibility to other browsers or official conformance tests. However, both may change in the future.

Any update on this topic as the next leap second will happen in just a few days time?
Labels: Type-FeatureRequest ES5
Status: WorkingAsIntended
The ES6 spec hasn't changed this, so V8's behaviour still seems correct and as required. If you care about leap seconds being allowed/handled in Date, I'm afraid you need to propose a spec change to the Ecma TC39 committee.

In the meantime I'm closing this bug.

Sign in to add a comment