How do JSON-RPC users handle datetimes?

571 views
Skip to first unread message

Andrew Pennebaker

unread,
Aug 23, 2013, 10:50:44 AM8/23/13
to json...@googlegroups.com
Do JSON-RPC users tend to use strings for datetimes? Could we reduce errors if there was a datetime data type in the JSON spec?

James Cooper

unread,
Aug 23, 2013, 5:29:10 PM8/23/13
to json...@googlegroups.com
On the last project I did we expressed time as milliseconds since epoch (e.g. System.currentTimeMillis() in Java).  

Good: easy to parse, no timezone issues.
Bad: not easily human readable

-- James


On Fri, Aug 23, 2013 at 7:50 AM, Andrew Pennebaker <apenne...@gmail.com> wrote:
Do JSON-RPC users tend to use strings for datetimes? Could we reduce errors if there was a datetime data type in the JSON spec?

--
You received this message because you are subscribed to the Google Groups "JSON-RPC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-rpc+u...@googlegroups.com.
To post to this group, send email to json...@googlegroups.com.
Visit this group at http://groups.google.com/group/json-rpc.
For more options, visit https://groups.google.com/groups/opt_out.



--

James Cooper
http://blog.bitmechanic.com/

Shane Green

unread,
Aug 23, 2013, 5:43:11 PM8/23/13
to json...@googlegroups.com, json...@googlegroups.com
Also, although a date/time data type might be useful in many ways, the data types available to JSON-RPC are defined by the JSON standard, and universal compatibility and consistency across platforms is probably the most important factor...  I've generally found ISO string representations are most "JSON" like in that they're both human readable and concise.  I definitely understand the motivation.

Sent from my iPad

Stephan Arts

unread,
Sep 12, 2013, 2:55:02 AM9/12/13
to json...@googlegroups.com
I always use the ISO 8601 Profile as described by W3C on http://www.w3.org/TR/NOTE-datetime

YYYY-MM-DDThh:mm:ss(Z|[+-]hh:mm)

Human readable, and precise enough for my needs possibly you could add something to support milliseconds like this:

YYYY-MM-DDThh:mm:ss(.uuu)?(Z|[+-]hh:mm)
Reply all
Reply to author
Forward
0 new messages