3 ms·
I find it curious that serialization formats like JSON get hit on for not having a native date/time format. Just use a UNIX timestamp and be done with it.
by RedShift1 6y ago
I find it curious that serialization formats like JSON get hit on for not having a native date/time format. Just use a UNIX timestamp and be done with it.
- bryanlarsen 6y agohttps://tools.ietf.org/html/rfc7493 https://tools.ietf.org/html/rfc7493 says to use an ISO 8601/RFC 3339 timestamp, uppercase, with timezone, with seconds. IOW, Javascript's toISOString() or equivalent.
- petre 6y agoYou need to parse that. For graphs with thousands of data points just use Unix time plus a timezone or use the browser's timezone. ISO 8601 would leave your graphs churning for seconds.
- bryanlarsen 6y agoIf parse time is a significant concern, why are you using JSON?
- petre 6y agoBecause we feed the data to Js. No need for additional overhead parsing string based timestamps. Unix epoch is just an int. We don't need pre 1970 timestamps.
- RedShift1 6y agoPre-1970 timestamps work too: Welcome to Node.js v12.18.4. Type ".help" for more information. > new Date(-10000) 1969-12-31T23:59:50.000Z
- Inufu 6y agoJavaScript can parse binary serialised protobufs.
- petre 6y agoYup with external libs. JSON.parse is builtin. We do the renderin in browser so why bother with protobuf.