2 ms·
> The support for datetimes is irrelevant if the protocol spec specifies how to serialize a date. Consider JSON and how numbers are handled right now. Per the
by ben509 6y ago
> The support for datetimes is irrelevant if the protocol spec specifies how to serialize a date.
Consider JSON and how numbers are handled right now.
Per the spec, it's an arbitrarily long decimal, and some libraries do deserialize it to a BigDecimal class.
But many libraries in a chain of processing will treat it as a double, often libraries outside your control.
So you can't rely on them preserving any accuracy beyond what a double can handle.
Likewise, if you have a complex date-time representation, the spec can require all kinds of detail, but in practice, some of that data will be thrown out.
And worse, they won't throw an error, they'll truncate that data quietly.
- dmitriid 6y agoMe: Datetime is one of the most used types beside the primitive ones. Let protocols specify what how it has to be serialized. This will serve as a baseline against which libraries will be measured. It significantly reduces questions on how to represent datetime, and libraries handling this have a significantly reduced space for caveats and errors. You: no-no-no, it won't work, let us make it significantly worse. Let us not specify this, and let everyone specify their own ad-hoc solutions with manual parsing and checks which will fail in every which way imaginable and let people serialise datetimes as `"\/Date(1320825600000-0800)\/"` for all I care because ... ?