#1 2016-12-30 04:56:34

avista
Member
Registered: 2014-01-06
Posts: 63

ISO 8601 to JSON -> No millisecond resolution

I know this has been covered before (e.g., http://synopse.info/forum/viewtopic.php?id=2047), but in my situation I have a datetime field that I'm returning in a JSON representation of a datetime value, where milliseconds is required in the ISO 8601 format.

Is there a reason milliseconds were omitted? 

Is there a way to for me to generically customize the JSON serialization routine to add support for milliseconds for *all* RTTI generic record serializations or do I need to create a customized serialization routine for every record I'm converting to JSON that has this requirement?

Thanks

Offline

#2 2016-12-30 05:27:47

Chaa
Member
Registered: 2011-03-26
Posts: 249

Re: ISO 8601 to JSON -> No millisecond resolution

See http://synopse.info/forum/viewtopic.php?id=3292 about my proposal.

There are slightly outdated patch. I plan to update it soon.

Offline

#3 2016-12-30 06:11:33

avista
Member
Registered: 2014-01-06
Posts: 63

Re: ISO 8601 to JSON -> No millisecond resolution

Thanks.  Hopefully this will get included by default in the near future. smile

Offline

#4 2016-12-30 15:05:53

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: ISO 8601 to JSON -> No millisecond resolution

I wish the ISO8601 datetime values stored by the framework has milliseconds too!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#5 2016-12-31 09:29:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: ISO 8601 to JSON -> No millisecond resolution

I still don't like much the use of conditional compilation to enable such a global feature.
In addition to milliseconds, appending "Z" as UTC time zone may make sense.

We may just switch to MS resolution everywhere for TDateTime.
Using TTimeLog for Seconds resolution and our Int64 bit-layared storage, and TDateTimeSec for TDateTime with Seconds resolution (the old behavior).
And I would like to add native TUnixTime type to the framework, which is known by SQLite3 and a lot of libraries (including JavaScript).
Backward compatibility will work by assuming MS=0 for old serialized content.

Offline

Board footer

Powered by FluxBB