clojure.instant
Reading RFC 3339 timestamps into instants. clojure.instant is loaded before the program, as
in Clojure, so clojure.instant/read-instant-date works without a require; it is Clojure
source written for rontolisp from the documented behavior of Clojure's namespace, and runs
the same on every backend. #inst reads through read-instant-date
(Syntax), unless a data reader of inst -- one of the
others in a data_readers.clj, or bound to *data-readers* around read-string -- reads
it first.
| Var | Behavior |
|---|---|
parse-timestamp | (parse-timestamp new-instant cs): matches the timestamp cs and calls new-instant with ten integers -- years, months, days, hours, minutes, seconds, nanoseconds, the offset's sign (-1, 0 or 1), hours and minutes; a missing month or day is 1, any other missing number 0, a fraction counts its first nine digits; anything else is the oracle's Unrecognized date/time syntax |
validated | (validated new-instance): new-instance behind the oracle's range checks of the ten integers, refusing the first that fails in the oracle's words (failed: (<= 1 months 12)) |
read-instant-date | (read-instant-date cs): the java.util.Date of the timestamp, its offset folded into UTC |
read-instant-timestamp | (read-instant-timestamp cs): the java.sql.Timestamp of the timestamp, which keeps all nine digits of its fraction |
read-instant-calendar | (read-instant-calendar cs): the java.util.Calendar of the timestamp, which keeps its offset |
[2020 1 1 10 20 30 500000000 1 5 30]
#inst "2020-01-01T10:20:30.123456789-00:00"
#inst "2020-01-01T10:20:30.000+05:30"
failed: (<= 1 days (days-in-month months (leap-year? years)))
A Timestamp is an instant like a Date: inst? and inst-ms take it, str of it is the
oracle's (2020-01-01 10:20:30.123456789), and like the oracle a Date is = to a Timestamp
of its milliseconds but a Timestamp is never = to a Date. A Calendar is no inst?; two are
= when their instants and zones are (-00:00 is another zone than Z), and compare orders
them by instant.
Differences
strof a Calendar answers its printed#inst, where the oracle's dumps the calendar's fields.