The ISO-8601 text codecs: between the ISO form on the wire and the value objects.
Pure. The regexes are the oracle's (tools/golden_check.clj): the golden table is the truth, and a parser that disagrees with it is the parser that is wrong.
There is no format here: a cljc pad keeps clj and cljs emitting the
same bytes.
Only the GENERIC ISO half lives here. The pt-BR half (br->dia, dia->br, competencia->br, competencia->extenso) and the wire parse (iso->periodo) stay in calendario's Portuguese facade.
Map keys are the generic English names (:year :month :day, :start :end).
The ISO-8601 text codecs: between the ISO form on the wire and the value objects. Pure. The regexes are the oracle's (tools/golden_check.clj): the golden table is the truth, and a parser that disagrees with it is the parser that is wrong. There is no `format` here: a cljc `pad` keeps clj and cljs emitting the same bytes. Only the GENERIC ISO half lives here. The pt-BR half (br->dia, dia->br, competencia->br, competencia->extenso) and the wire parse (iso->periodo) stay in calendario's Portuguese facade. Map keys are the generic English names (:year :month :day, :start :end).
(format-day d)Day -> "YYYY-MM-DD", each field zero-padded.
Day -> "YYYY-MM-DD", each field zero-padded.
(format-month m)Month -> "YYYY-MM", each field zero-padded.
Month -> "YYYY-MM", each field zero-padded.
(format-period p)A Period as an object of two ISO Days, with the generic English keyword keys (:start :end) -- the facade renames them to the wire's common.v1 shape. The period is validated first: a missing end -> :time/period-missing-bound, never the zero date; start > end -> :time/period-inverted.
A Period as an object of two ISO Days, with the generic English keyword keys (:start :end) -- the facade renames them to the wire's common.v1 shape. The period is validated first: a missing end -> :time/period-missing-bound, never the zero date; start > end -> :time/period-inverted.
(format-time h)The codec RULE: "HH:MM" when the second is 0, else "HH:MM:SS". Each field zero-padded.
The codec RULE: "HH:MM" when the second is 0, else "HH:MM:SS". Each field zero-padded.
(parse-day s)"YYYY-MM-DD" -> Day. A WELL-FORMED instant is the WRONG type, not a format error: the refusal is :time/day-is-instant, and it is checked FIRST (the oracle's order). Not text, or not ISO -> :time/day-format; impossible day -> :time/day-impossible; year outside 1900..2199 -> :time/day-out-of-range.
"YYYY-MM-DD" -> Day. A WELL-FORMED instant is the WRONG type, not a format error: the refusal is :time/day-is-instant, and it is checked FIRST (the oracle's order). Not text, or not ISO -> :time/day-format; impossible day -> :time/day-impossible; year outside 1900..2199 -> :time/day-out-of-range.
(parse-month s)"YYYY-MM" -> Month. An instant -> :time/month-is-instant; not YYYY-MM -> :time/month-impossible (sic, the oracle's choice).
"YYYY-MM" -> Month. An instant -> :time/month-is-instant; not YYYY-MM -> :time/month-impossible (sic, the oracle's choice).
(parse-time s)The legacy layouts 'H', 'H:M' and 'H:M:S' -> TimeOfDay. Not text, or off the layout -> :time/time-format; a field out of range -> :time/time-out-of-range.
The legacy layouts 'H', 'H:M' and 'H:M:S' -> TimeOfDay. Not text, or off the layout -> :time/time-format; a field out of range -> :time/time-out-of-range.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |