clojure-emacs / parseedn

EDN parser for Emacs Lisp
58 stars 14 forks source link

handle timezones and milliseconds when parsing/printing inst #8

Open plexus opened 3 years ago

plexus commented 3 years ago

Currently we use date-to-time to parse inst, which ignores milliseconds and timezones. Seems there are a number of competing ways to represent time in elisp.

The Time of Day info docs mention this format: (sec-high sec-low microsec picosec), but the higher precision numbers may be omitted, which is what date-to-time does, so it just returns a pair of (sec-high sec-low)

encode-time/decode-time convert between this "lisp timestamp" format and (SECOND MINUTE HOUR DAY MONTH YEAR IGNORED DST ZONE). Note that while this does have time zone info, it does not have sub-second resolution.

Emacs 27 adds iso8601.el which adds iso8601-parse, which returns the same structure as decode-time shown above, so again without milliseconds.

There is no inverse iso8601-format, it is not clear to me how one is supposed to format an ISO8601 time stamp. Ergoemacs shows a snippet that combines multiple invocations of format-time-string.

I think with some cobbling together of what Emacs offers we should be able to at least support time zone parsing and printing, I think that's also the more urgent issue, although millisecond/nanosecond resolution would certainly be nice to have as well.