Closed Bug 1275502 Opened 8 years ago Closed 8 years ago

Date.parse() does not treat the absence of time zone offset as UTC time

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox46 --- wontfix
firefox47 --- wontfix
firefox48 --- wontfix
firefox49 --- wontfix
firefox-esr38 --- wontfix
firefox-esr45 --- wontfix

People

(Reporter: cpeterson, Unassigned)

References

(Blocks 1 open bug)

Details

The expression:

Date.parse('2011-11-29T15:52:18.867') === Date.parse('2011-11-29T15:52:18.867Z')

returns true in Chrome and Safari (and supposedly IE9?!).
returns false in Firefox, Edge, IE11, IE10, and IE8.

Because:

+new Date('2011-11-29T15:52:18.867') === 1322610738867
+new Date('2011-11-29T15:52:18.867Z') === 1322581938867

According to http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15, the "value of an absent time zone offset is “Z”."

This discrepancy was originally reported as an IE bug:

https://connect.microsoft.com/IE/feedback/details/776783/date-parse-and-new-date-fail-on-valid-formats
This is a known spec bug from ECMAScript5 [1], fixed in ES2016, ES2017 [2,3]:
---
When the time zone offset is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time.
---

[1] https://bugs.ecmascript.org/show_bug.cgi?id=112
[2] https://tc39.github.io/ecma262/2016/#sec-date-time-string-format
[3] https://tc39.github.io/ecma262/#sec-date-time-string-format
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
btw, Chrome still treats date-time forms without a time zone offset as UTC, not local time:

Date.parse('2001-01-01T01:01:01.001') === Date.parse('2001-01-01T01:01:01.001Z') is true in Chrome, but false in Firefox and Edge.

Here is the Chromium bug report:

https://crbug.com/589858
You need to log in before you can comment on or make changes to this bug.