The zone seam: the ONE place the library touches the platform.
Every other namespace is pure. Here lives the bridge between a Day and an instant, and it is a FUNCTION OF A LIBRARY, never a field of a Day.
The zone is ALWAYS an explicit argument: ttrack has NO default zone. A library that silently reaches for America/Sao_Paulo is exactly the coupling this coordinate was carved out to break.
The two rules the dst-* rows fix, on BOTH legs:
clj leg: java.time ZoneId / LocalDateTime with getValidOffsets. cljs leg: Intl.DateTimeFormat with formatToParts, hourCycle h23, cached per zone in a js/Map, plus a two-candidate offset search. NO tz library -- the zone rules come from the engine's ICU tzdata.
Map keys are the generic English names (:year :month :day, :hour :minute :second, :start :end).
The zone seam: the ONE place the library touches the platform.
Every other namespace is pure. Here lives the bridge between a Day and an
instant, and it is a FUNCTION OF A LIBRARY, never a field of a Day.
The zone is ALWAYS an explicit argument: ttrack has NO default zone. A
library that silently reaches for America/Sao_Paulo is exactly the coupling
this coordinate was carved out to break.
The two rules the dst-* rows fix, on BOTH legs:
- a gap (DST start) is an EXPLICIT error (:time/zone-gap), never a silent
shift of the wall clock;
- in an overlap (DST end) the EARLIEST offset wins, deterministically
(java.time's default; the cljs two-candidate search's min).
clj leg: java.time ZoneId / LocalDateTime with getValidOffsets.
cljs leg: Intl.DateTimeFormat with formatToParts, hourCycle h23, cached per
zone in a js/Map, plus a two-candidate offset search. NO tz library -- the
zone rules come from the engine's ICU tzdata.
Map keys are the generic English names (:year :month :day, :hour :minute
:second, :start :end).(->zone zone)Validating constructor: an IANA zone id -> the ZoneId. A non-string, an empty string, or an id the platform does not know -> :time/zone-unknown.
The ZoneId IS the id string; the platform handle is derived on each call and never stored in a value, so a value is comparable and serialisable.
Validating constructor: an IANA zone id -> the ZoneId. A non-string, an empty string, or an id the platform does not know -> :time/zone-unknown. The ZoneId IS the id string; the platform handle is derived on each call and never stored in a value, so a value is comparable and serialisable.
(day->instant d zone)The op-table name for day-start: the instant a Day begins in a zone.
The op-table name for `day-start`: the instant a Day begins in a zone.
(day-start d zone)The first instant of day in zone (= atStartOfDay).
On a DST-gap day 00:00 never happened: the instant is 00:00 read in the offset BEFORE the transition, so America/Sao_Paulo 2018-11-04 -> 03:00Z. It never refuses -- a day always begins somewhere.
The first instant of `day` in `zone` (= atStartOfDay). On a DST-gap day 00:00 never happened: the instant is 00:00 read in the offset BEFORE the transition, so America/Sao_Paulo 2018-11-04 -> 03:00Z. It never refuses -- a day always begins somewhere.
(instant->day instant zone)The Day of instant in zone. The ZONE is the argument, never a field of
the value -- that is the whole correction.
The Day of `instant` in `zone`. The ZONE is the argument, never a field of the value -- that is the whole correction.
(instant->local instant zone)The wall clock of instant in zone: {:day Day :time TimeOfDay}.
The wall clock of `instant` in `zone`: {:day Day :time TimeOfDay}.
The wall-clock value object (instant->local) as a CLOSED malli map wrapped in its invariant: {:day Day :time TimeOfDay}.
The wall-clock value object (instant->local) as a CLOSED malli map wrapped in
its invariant: {:day Day :time TimeOfDay}.(local->instant d h zone)The instant of a wall clock (a Day + a TimeOfDay) in zone.
The gap/overlap policy is EXPLICIT, never a silent shift:
The instant of a wall clock (a Day + a TimeOfDay) in `zone`.
The gap/overlap policy is EXPLICIT, never a silent shift:
- a gap (the wall clock never happened, DST start) -> :time/zone-gap;
- an overlap (the wall clock happened twice, DST end) -> the EARLIEST
offset, deterministically.(local-time->instant d h zone)The op-table name for local->instant: a local Day + TimeOfDay in a zone ->
epoch ms; a gap -> :time/zone-gap, an overlap -> the earliest offset.
The op-table name for `local->instant`: a local Day + TimeOfDay in a zone -> epoch ms; a gap -> :time/zone-gap, an overlap -> the earliest offset.
(local? x)True when x is a wall clock: a valid Day and a valid TimeOfDay. Never
throws.
True when `x` is a wall clock: a valid Day and a valid TimeOfDay. Never throws.
(offset-ms instant zone)The zone offset at instant, in ms: wall-clock-as-UTC-ms - instant.
The zone offset at `instant`, in ms: wall-clock-as-UTC-ms - instant.
(period->instant-interval p zone)A Period as a HALF-OPEN interval of instants [start@00:00, (end+1)@00:00) in
zone. Never +86400 s, never 23:59:59. The period is validated first: a
missing end -> :time/period-missing-bound, start > end ->
:time/period-inverted.
A Period as a HALF-OPEN interval of instants [start@00:00, (end+1)@00:00) in `zone`. Never +86400 s, never 23:59:59. The period is validated first: a missing end -> :time/period-missing-bound, start > end -> :time/period-inverted.
(period-contains-instant? p zone t)a <= t < b.
a <= t < b.
The ZoneId value object as a malli schema. A zone id is a STRING, so there is no closed map to wrap: the schema is the base type wrapped in the invariant (zone?), never shape-only. Step-8's schema.cljc re-exports this.
The ZoneId value object as a malli schema. A zone id is a STRING, so there is no closed map to wrap: the schema is the base type wrapped in the invariant (zone?), never shape-only. Step-8's schema.cljc re-exports this.
(zone? zone)True when zone is a usable zone id on this platform. Never throws.
True when `zone` is a usable zone id on this platform. Never throws.
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 |