Description
Originally filed by darron.schall on 2006-12-29T20:44:29
What steps will reproduce the problem?
- trace( JSON.encode( new Date() ) );
What is the expected output? What do you see instead?
The expected output, unfortunately, is not that well defined. There is no
standard JSON syntax for dealing with dates. A proposed standard is here:
http://www.nikhilk.net/DateSyntaxForJSON2.aspx
Essentially, serializing the date to "@Number@" where number is the number
of milliseconds that have passed since Jan 1, 1970.
Either that, or we can use one of the ISO Date Standard formats.
The output from the trace statement is simply {}. Clearly an empty object
is not good, not matter what the expected output should be.
Please use labels and text to provide additional information.
Whatever sort of serialization we implement should probably be specified
via a flag, passed to the static encode/decode methods. Something like:
JSON.encode( date, JSON.DATE_FORMAT_ISO_8601 );
or
JSON.encode( date, JSON.DATE_FORMAT_AT_MILLIS_AT );
Also, a the decode routine should be specified so that string matching the
encoding format will be converted into true Date instances.