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
Last visit > 30 days ago
Closed: Feb 2012
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: FeatureRequest

Sign in to add a comment

Date.parse doesn't accept leap second

Reported by, Feb 12 2012

Issue description

In ECMA262 5.1 section, 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.

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

1.6 KB View Download
Above patch considers 60 over seconds.

for example,


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

On the other hand, JSC clamp this to 60 second.
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.

2.1 KB View Download
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