7 ms·
JSON is also missing a date type. Sure, you can use a string serialization but that's ambiguous. It's also non-extensible so these types it's missing cannot be
by eyelidlessness 7y ago
JSON is also missing a date type. Sure, you can use a string serialization but that's ambiguous.
It's also non-extensible so these types it's missing cannot be added without assumptions or overhead from convention.
Transit is a good solution to this.
- kenoyer130 7y agoTHIS! Not having a defined Date format has caused so much confusion with consumers of our API since every json API might have a different ISO date format (or some homegrown madness).
- eyelidlessness 7y agoIn APIs I've integrated in recent years, I've seen: 1. ISO UTC 2. ISO local 3. Epoch 4. 2018-04-20 5. Jan 01 2016 11:58am Probably others that I can't recall. It's a damn mess.
- anamexis 7y agoTo be fair, 1, 2 and 4 are all just ISO.
- eyelidlessness 7y agoThat's true. But 2 is substantially less useful than 1 and I encountered 4 mixed with 3.
- Jestar342 7y ago`/Date(1234567890)/` That will probably cause a twitch to any dev that used Asp.NET up until a few years ago.
- thawaway1837 7y agoI’m twitching away...
- eyelidlessness 7y agoWow :(
- srgpqt 7y agoI had to deal with that two weeks ago. Cringe.
- clon 7y agoPHP-s strtotime() will probably handle them all, even though it will make you cringe a bit. I never understood why simple integer unix timestamps are not more prevalent in API-s? Or some monotonic count from any reasonable epoch, depending on the context. How many APIs really have to ever return dates predating unix?
- bzbz 7y agoWhy wouldn't you just use epoch time?
- eyelidlessness 7y ago1. It is lower fidelity (seconds vs milliseconds). 2. It's also not a type. How do you distinguish epoch from number?
- Minor49er 7y ago1. You could use a float. 2. Probably in the documentation of whatever it is that's using it
- nitrogen 7y agoEpoch floats and doubles are not good for timestamps, as the further we get from 1970 the less precise they become. Current precision with a 32-bit float (JSON/JavaScript are 64-bit usually, though in non-JS it's common to use Bigdecimal in slight non-compliance) is much worse than one second.
- ci5er 7y agoFloats are ugly because the distance between any two successive numbers are not the same. This makes them inappropriate for discretized time and anything accounting-related (money).
- stickfigure 7y ago> in the documentation of whatever it is that's using it That's the point, timestamps should be self-describing. If "look up the structure in documentation" suffices we might as well just use protobufs.
- eyelidlessness 7y ago1. YUK 2. ISO 8601 is a better format for this.
- a1369209993 7y ago