Closed Bug 730831 Opened 13 years ago Closed 10 years ago

Date.prototype.toISOString returns not a valid ISO-8601 string

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: anba, Assigned: anba, Mentored)

References

Details

(Whiteboard: [lang=C++])

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 Build ID: 20120215223356 Steps to reproduce: js> new Date("+020000-01-01T00:00:00.000Z").toISOString() Actual results: SM returns the string "20000-01-01T00:00:00.000Z" Expected results: toISOString() should return a valid ISO-8601 Extended Format string with expanded years representation. But also see https://bugs.ecmascript.org/show_bug.cgi?id=119 about the current under-specification of toISOString().
Same here. toISOString is not using Extended Format for years outside 0000..9999. I.e. not using signed 6-digit extended years, according to ES5 spec section 15.9.1.15.1
Marking as 'new' due to the already confirmed cases and my own. When trying to understand why the JSON3 [1] library partially "failed" in Firefox, falling-back to a script-based implementation for the 'stringify' part (the 'parse' seems to be properly working, though), I noticed that the particular test [2] (here simplified) which made the correctness of the API fail was similar to: var stringifySupported = JSON.stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"'; This causes Firefox to serialize the date as "275760-09-13T00:00:00.000Z", thereby missing the positive sign, which is mandatory in extended years according to ES5.1 - 15.9.1.15.1 [3]. (On the other hand, negative extended dates seem to be properly working in this scope.) This is somehow annoying as this library usage seems to be increasing and also because it's a valid correctness test which is failing with a reason. Finally, for strict web services which start to adopt this "new" format for Date object serializing into JSON, this issue may cause content including extended years (which are arguably rare, but that's my experience) to be discarded for this reason. As a side note, the under-specification of 'toISOString' issue, stated in comment #0, is already addressed and properly marked as "fixed". [1] https://github.com/bestiejs/json3 [2] https://github.com/bestiejs/json3/blob/gh-pages/lib/json3.js#L139 [3] http://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [mentor=bzbarsky@mit.edu][lang=C++]
Mentor: bzbarsky
Whiteboard: [mentor=bzbarsky@mit.edu][lang=C++] → [lang=C++]
Assignee: general → nobody
(Adding link to relevant issue created for JSON3 to "See Also" field in the scope of comment #3.)
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8511648 - Flags: review?(bzbarsky)
OS: Windows 7 → All
Hardware: x86_64 → All
Comment on attachment 8511648 [details] [diff] [review] bug730831_Date_toISO_extended.patch I'm not a JS peer, sorry.
Attachment #8511648 - Flags: review?(bzbarsky) → review?(jorendorff)
Comment on attachment 8511648 [details] [diff] [review] bug730831_Date_toISO_extended.patch Review of attachment 8511648 [details] [diff] [review]: ----------------------------------------------------------------- Thanks again!
Attachment #8511648 - Flags: review?(jorendorff) → review+
Pinging as a positively reviewed patch is available for a trimester already, so (apparently) no reason for leaving this issue open...? ;-)
Pushed to try here: https://treeherder.mozilla.org/#/jobs?repo=try&revision=4874745e2c81 Thanks for the ping, Lthere.
Attachment #8511648 - Attachment is obsolete: true
Attachment #8555811 - Flags: review+
Preemptively setting checkin-needed as I don't see why this should fail.
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: