couchbase/fleece

Support for dates/times

snej opened this issue · 2 comments

snej commented

Dates are really common in real-world JSON data, so it would be nice to have a data type for them. Internally it would be something numeric like a Unix time_t (seconds since 1/1/1970). When converting to JSON it could be written as an ISO-8601 string.

At one point I had a tag reserved for dates, but I ran out of room and had to give it up. There are still some free bits in the float format, though...

What ever format you use internal it should support timezones. For example: Unix time_t + Timezone code

snej commented

FLEncoder_WriteDateString and FLValue_AsTimestamp were added a while ago. There's no special type for dates, though. The first function writes an ISO-8601 string, and the second function parses either that format. (Or if given a number, interprets as a timestamp, expressed as milliseconds since the Unix epoch.)