Closed
Bug 647568
Opened 14 years ago
Closed 8 years ago
Incorrect parsing of ISO 8601 date
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1275502
People
(Reporter: kuvik3, Assigned: dmandelin)
References
()
Details
Attachments
(1 file)
|
2.00 KB,
patch
|
Waldo
:
review-
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0
If I use
new Date("2011-07-02")
to parse ISO 8601 date, Firefox should add missing time information as 00:00:00.000 in _local_ time zone, so when I ask for getUTCHours(), it should return "22" (I live in timezone +02:00)
Firefox 4 returns "0" instead, which is, I think, not correct.
- Chrome and Opera returns "22" correctly.
- IE9 also returns "0", but they incorrectly treat all date inputs without timezone set as UTC timezone.
- WebKit doesn't support Date(ISO8601 string) yet.
Reproducible: Always
| Assignee | ||
Updated•14 years ago
|
Assignee: general → dmandelin
| Assignee | ||
Comment 3•14 years ago
|
||
Attachment #531653 -
Flags: review?(jwalden+bmo)
Comment 4•14 years ago
|
||
Comment on attachment 531653 [details] [diff] [review]
Patch
There's a bug here, but it's not that "2011-07-01" is interpreted as local time. It's that it's not interpreted as UTC! I think IE9 is the only browser with correct behavior here at present.
http://wiki.ecmascript.org/lib/exe/fetch.php?id=start&cache=cache&media=resources:tc39-2010-062-rev5p.pdf
According to the latest errata, if the time zone offset is absent, it is to be treated as "Z", which produces UTC. So I think the right fix here is to remove the |isLocalTime| variable, its assignments, and its uses entirely.
Attachment #531653 -
Flags: review?(jwalden+bmo) → review-
Comment 5•14 years ago
|
||
I agree with Jeff's reading of ECMA-262 edition 5.1, but that behavior actually contradicts ISO 8601:2004(E). I filed a bug on the ECMAScript tracker: https://bugs.ecmascript.org/show_bug.cgi?id=112
Comment 6•14 years ago
|
||
Interesting! Good to have other people looking at this stuff (presumably with more domain knowledge than I have?), thanks for catching that.
Comment 7•13 years ago
|
||
This is the same issue as in bug 570179. bug 570179, comment 4 also points out the different behaviour between date-only and date-time forms, i.e. date-only forms get UTC as the default timezone whereas date-time forms without a timezone specifier get the local timezone.
Comment 8•13 years ago
|
||
This is a known bug in the ES5 and %.1 spec. See https://bugs.ecmascript.org/show_bug.cgi?id=112
The ES6 draft currently says "If the time zone offset is absent, the date-time is interpreted as a local time."
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•