Liking cljdoc? Tell your friends :D

hive-ttracking.time.day

The Day, and calendar arithmetic over it.

A Day is {:year int :month int :day int}, the calendar day as a person says it. It carries no zone, ever: the ambiguity that comes from writing a day as midnight in one zone and reading it in another is the whole reason a day is not an instant.

The arithmetic is by epoch-day, integer (Hinnant days_from_civil / civil_from_days): no floats, no js/Date, no java.time. That is why the same function answers the same in clj and cljs, and why a day does not depend on the process zone.

The map keys are the generic English names (:year :month :day). calendario's Portuguese facade renames them at its own boundary.

The Day, and calendar arithmetic over it.

A Day is {:year int :month int :day int}, the calendar day as a person says
it. It carries no zone, ever: the ambiguity that comes from writing a day as
midnight in one zone and reading it in another is the whole reason a day is
not an instant.

The arithmetic is by epoch-day, integer (Hinnant days_from_civil /
civil_from_days): no floats, no js/Date, no java.time. That is why the same
function answers the same in clj and cljs, and why a day does not depend on
the process zone.

The map keys are the generic English names (:year :month :day). calendario's
Portuguese facade renames them at its own boundary.
raw docstring

->dayclj/s

(->day year month day)

Validating constructor. Checks IMPOSSIBLE first (a LocalDate/of would throw), then the range: a year outside 1900..2199 -> :time/day-out-of-range; a month outside 1..12 or a day outside 1..(days-in-month) -> :time/day-impossible. The order is the oracle's: 0001-01-01 -> :time/day-out-of-range, 2026-02-31 -> :time/day-impossible, 13/13/2026 -> :time/day-impossible.

Validating constructor. Checks IMPOSSIBLE first (a LocalDate/of would
throw), then the range: a year outside 1900..2199 -> :time/day-out-of-range;
a month outside 1..12 or a day outside 1..(days-in-month) ->
:time/day-impossible. The order is the oracle's: 0001-01-01 ->
:time/day-out-of-range, 2026-02-31 -> :time/day-impossible,
13/13/2026 -> :time/day-impossible.
sourceraw docstring

add-daysclj/s

(add-days d n)

d plus n days, revalidated by ->day (range).

`d` plus `n` days, revalidated by ->day (range).
sourceraw docstring

compare-dayclj/s

(compare-day a b)

Day comparator: negative when a < b.

Day comparator: negative when `a` < `b`.
sourceraw docstring

day-of-weekclj/s

(day-of-week d)

ISO day of week: 1=Monday .. 7=Sunday. 1970-01-01 was a Thursday (=4).

ISO day of week: 1=Monday .. 7=Sunday. 1970-01-01 was a Thursday (=4).
sourceraw docstring

day?clj/s

(day? x)

True when x is structurally a Day AND a real day in range. Never throws.

True when `x` is structurally a Day AND a real day in range. Never throws.
sourceraw docstring

days-betweenclj/s

(days-between from to)

Exact days from from to to: may be negative. Never ms/86400000.

Exact days from `from` to `to`: may be negative. Never ms/86400000.
sourceraw docstring

days-in-monthclj/s

(days-in-month year month)

How many days month has in year.

How many days `month` has in `year`.
sourceraw docstring

epochclj/s

(epoch d)

The epoch-day of an already-built Day.

The epoch-day of an already-built Day.
sourceraw docstring

epoch-dayclj/s

(epoch-day year month day)

Days since 1970-01-01 (epoch-day). Hinnant days_from_civil, integer.

Days since 1970-01-01 (epoch-day). Hinnant days_from_civil, integer.
sourceraw docstring

from-epoch-dayclj/s

(from-epoch-day n)

The Day of an epoch-day. Hinnant civil_from_days, integer.

The Day of an epoch-day. Hinnant civil_from_days, integer.
sourceraw docstring

leap-year?clj/s

(leap-year? year)

True when year is a leap year in the Gregorian calendar.

True when `year` is a leap year in the Gregorian calendar.
sourceraw docstring

max-yearclj/s

source

min-yearclj/s

source

weekend?clj/s

(weekend? d)

Saturday or Sunday.

Saturday or Sunday.
sourceraw docstring

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