[TIMOB-1600] Android: JSON.stringify incorrectly handles dates including silently faiing
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2011-04-17T01:56:38.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 1.5.0 M02 |
| Components | Android |
| Labels | android, date, defect, json.stringify |
| Reporter | lukaso |
| Assignee | Don Thorp |
| Created | 2011-04-15T02:57:04.000+0000 |
| Updated | 2011-04-17T01:56:38.000+0000 |
Description
Here is the output of JSON.stringify on a number of different platforms, including Android. As you can see, the Android version handles both a date directly incorrectly, and embedded in an object incorrectly, but differently.
This bug makes it very difficult to send date information to servers or store it in local state.
Firefox:
JSON.stringify(new Date()) => "2010-08-19T09:12:00.027Z"
JSON.stringify({time: new Date()}) =>
{"time":"2010-08-19T09:13:30.025Z"}
Chrome:
JSON.stringify(new Date()) => "2010-08-19T09:14:16.527Z"
JSON.stringify({time: new Date()}) =>
{"time":"2010-08-19T09:14:55.028Z"}
Titanium iPhone:
JSON.stringify(new Date()) => "2010-08-19T09:21:22.528Z"
JSON.stringify({time: new Date()}) =>
{"time":"2010-08-19T09:21:22.528Z"}
Titanium Android:
JSON.stringify(new Date()) => "Thu Aug 19 10:19:00
Europe/London 2010" JSON.stringify({time: new Date()}) =>
{}
(from [c680f8c261118315c9160a96ce05bcbc08eda14f]) compensate for JS timezone offsets in date conversion (Java Dates are GMT), use the same JSON format used by browsers for JSON stringifying Dates. added a test for dates and JSON [#1600 state:fixed-in-qa milestone:"Release 1.5.0 M02"] https://github.com/appcelerator/titanium_mobile/commit/c680f8c261118315c9160a96ce05bcbc08eda14f"> https://github.com/appcelerator/titanium_mobile/commit/c680f8c26111...
Passed Android Version 1.6 Sim, Titanium SDK version: 1.5.0 (11/24/10 12:05 c0aff27)
Passed Android Versions 2.1 Sim, Titanium SDK version: 1.5.0 (11/24/10 12:05 c0aff27)