Liking cljdoc? Tell your friends :D

datahike.pg.datetime.carrier

The port's canonical values in the carriers the rest of pg-datahike already uses.

The parser returns PostgreSQL's own internal form -- a day count, or microseconds from an epoch. Everything downstream expects java.time.LocalDate, LocalTime, OffsetTime, LocalDateTime or java.util.Date, with two established conventions for the values those classes cannot hold. This namespace is the one place the two meet, and it is deliberately thin: the conversion is where precision is lost, so it should be visible rather than spread across call sites.

THREE THINGS THE CARRIERS CANNOT HOLD, each with a convention that predates this port:

24:00:00 is a legal PostgreSQL time and java.time.LocalTime has no end-of-day value. It is carried as the TEXT "24:00:00", which stores, renders and orders correctly because time values are kept as their canonical text.

The two infinities have no java.util.Date room, so they are the sentinels types/pos-infinity and types/neg-infinity.

MICROSECONDS survive LocalDateTime, LocalTime and OffsetDateTime, and do NOT survive java.util.Date, which is millisecond-only. The parser is not the lossy step and never was -- this conversion is, and only on the paths that must hand back a Date.

The port's canonical values in the carriers the rest of pg-datahike
already uses.

The parser returns PostgreSQL's own internal form -- a day count, or
microseconds from an epoch. Everything downstream expects
`java.time.LocalDate`, `LocalTime`, `OffsetTime`, `LocalDateTime` or
`java.util.Date`, with two established conventions for the values
those classes cannot hold. This namespace is the one place the two
meet, and it is deliberately thin: the conversion is where precision
is lost, so it should be visible rather than spread across call
sites.

THREE THINGS THE CARRIERS CANNOT HOLD, each with a convention that
predates this port:

`24:00:00` is a legal PostgreSQL time and `java.time.LocalTime` has
no end-of-day value. It is carried as the TEXT `"24:00:00"`, which
stores, renders and orders correctly because time values are kept
as their canonical text.

The two infinities have no `java.util.Date` room, so they are the
sentinels `types/pos-infinity` and `types/neg-infinity`.

MICROSECONDS survive `LocalDateTime`, `LocalTime` and
`OffsetDateTime`, and do NOT survive `java.util.Date`, which is
millisecond-only. The parser is not the lossy step and never was --
this conversion is, and only on the paths that must hand back a
`Date`.
raw docstring

->dateclj

(->date r)

:date to LocalDate, or an infinity sentinel.

`:date` to `LocalDate`, or an infinity sentinel.
sourceraw docstring

->date-valueclj

(->date-value r)

:timestamp/:timestamptz to java.util.Date.

THIS IS THE LOSSY ONE. java.util.Date is millisecond-only, so .123456 becomes .123. Used where a store or a wire path still expects a Date; prefer ->local-datetime wherever the caller can take it.

`:timestamp`/`:timestamptz` to `java.util.Date`.

THIS IS THE LOSSY ONE. `java.util.Date` is millisecond-only, so
`.123456` becomes `.123`. Used where a store or a wire path still
expects a Date; prefer `->local-datetime` wherever the caller can
take it.
sourceraw docstring

->local-datetimeclj

(->local-datetime r)

:timestamp/:timestamptz to LocalDateTime, which keeps microseconds, or an infinity sentinel.

`:timestamp`/`:timestamptz` to `LocalDateTime`, which keeps
microseconds, or an infinity sentinel.
sourceraw docstring

->offset-datetimeclj

(->offset-datetime r)

:timestamptz to OffsetDateTime at +00.

The microsecond-preserving carrier for a timestamptz. types/->pg-text already renders one with its offset, so this keeps BOTH the +00 that a timestamptz must print and the precision a java.util.Date drops -- which were previously a choice of one or the other.

`:timestamptz` to `OffsetDateTime` at +00.

The microsecond-preserving carrier for a timestamptz. `types/->pg-text`
already renders one with its offset, so this keeps BOTH the `+00`
that a timestamptz must print and the precision a `java.util.Date`
drops -- which were previously a choice of one or the other.
sourceraw docstring

->timeclj

(->time r)

:time to LocalTime, or the text "24:00:00" for end of day.

`:time` to `LocalTime`, or the text `"24:00:00"` for end of day.
sourceraw docstring

->timetzclj

(->timetz r)

:timetz to OffsetTime, or the end-of-day text with its offset.

`:timetz` to `OffsetTime`, or the end-of-day text with its offset.
sourceraw docstring

end-of-day-usecclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close