WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
29063
JSON.stringify(Date) loses the milliseconds information
https://bugs.webkit.org/show_bug.cgi?id=29063
Summary
JSON.stringify(Date) loses the milliseconds information
Shumpei Shiraishi
Reported
2009-09-08 18:37:36 PDT
Created
attachment 39241
[details]
Test case for this bug. I tried to use the JSON.stringify() for Date object on Safari4 and WebKit nightly build(48096), so I got result as follows.
> JSON.stringify(new Date()); > 2009-09-07T04:49:43Z
This result seems that milliseconds information of date is lost. For some applications, millis info is important and this behavior may be problem. And in the ECMAScript 5th specification, Date.toISOString() (this function is called from Date.prototype.toJSON()) is defined as: ...Date Time string format (15.9.1.15). *All fields are present* in the string... So, I think the Webkit's behavior should be treated as a bug, isn't it? P.S. Current implementations' status is as follows (tested by attached test case): Firefox3.5: keep milliseconds Webkit: lost milliseconds Opera10: not yet implemented IE8: lost milliseconds Mmm... IE8's behavior is same as Webkit. Is current behavior collect? Is JSON.stringify() useless for apps which want to treat the information of milliseconds?
Attachments
Test case for this bug.
(750 bytes, text/html)
2009-09-08 18:37 PDT
,
Shumpei Shiraishi
no flags
Details
Patch v1
(5.72 KB, patch)
2009-09-08 23:33 PDT
,
Oliver Hunt
mjs
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Oliver Hunt
Comment 1
2009-09-08 18:55:23 PDT
> Mmm... IE8's behavior is same as Webkit. > Is current behavior collect? Is JSON.stringify() useless for apps which want to > treat the information of milliseconds?
Per spec it is incorrect, but that said, toJSON is a function like any other, eg. Date.prototype.toJSON = function() { ... }
Shumpei Shiraishi
Comment 2
2009-09-08 20:20:04 PDT
> Per spec it is incorrect, but that said, toJSON is a function like any other, > eg. > Date.prototype.toJSON = function() { > ... > }
OK, I see. And I wrote a JS library for ISO-8601 date format. It is useful to implement the custom Date.prototype.toJSON().
http://wiki.github.com/shumpei/iso8601.js/
Oliver Hunt
Comment 3
2009-09-08 23:33:46 PDT
Created
attachment 39250
[details]
Patch v1
Maciej Stachowiak
Comment 4
2009-09-09 00:00:43 PDT
Comment on
attachment 39250
[details]
Patch v1 r=me
Oliver Hunt
Comment 5
2009-09-09 00:10:30 PDT
Landed
r48202
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug