Liking cljdoc? Tell your friends :D

baredom.utils.dates

Pure UTC date primitives shared by date components (x-date-picker, x-calendar). No DOM, no side effects — every function is a value transform. Dates are JS Date objects pinned to UTC midnight; ISO strings are "YYYY-MM-DD".

first-day-of-week (fdow) is 0=Sunday .. 6=Saturday. The start-of-week / end-of-week / month-grid functions default to 0 (Sunday) so existing single-arity callers keep their behaviour.

Pure UTC date primitives shared by date components (x-date-picker,
x-calendar). No DOM, no side effects — every function is a value
transform. Dates are JS `Date` objects pinned to UTC midnight; ISO
strings are `"YYYY-MM-DD"`.

`first-day-of-week` (`fdow`) is `0`=Sunday .. `6`=Saturday. The
`start-of-week` / `end-of-week` / `month-grid` functions default to
`0` (Sunday) so existing single-arity callers keep their behaviour.
raw docstring

add-dayscljs

(add-days d n)

Return a new Date that is d + n days (UTC).

Return a new Date that is d + n days (UTC).
sourceraw docstring

add-monthscljs

(add-months d n)

Return a new Date that is d +/- n months (UTC). Clamps day to target month's last day when overflow would occur (e.g. Jan 31 + 1 → Feb 28).

Return a new Date that is d +/- n months (UTC). Clamps day to target
month's last day when overflow would occur (e.g. Jan 31 + 1 → Feb 28).
sourceraw docstring

clamp-to-rangecljs

(clamp-to-range d min-d max-d)

Clamp d to [min-d, max-d]. Either bound may be nil (unbounded).

Clamp d to [min-d, max-d]. Either bound may be nil (unbounded).
sourceraw docstring

compare-datecljs

(compare-date a b)

Returns -1, 0, or 1 comparing two UTC dates by day only.

Returns -1, 0, or 1 comparing two UTC dates by day only.
sourceraw docstring

date->isocljs

(date->iso d)

JS Date → "YYYY-MM-DD" using UTC fields.

JS Date → "YYYY-MM-DD" using UTC fields.
sourceraw docstring

days-in-monthcljs

(days-in-month d)

Number of days in d's UTC month.

Number of days in d's UTC month.
sourceraw docstring

end-of-weekcljs

(end-of-week d)
(end-of-week d fdow)

Return the last day of d's week (UTC), 6 days after start-of-week. fdow defaults to 0 (Sunday → Saturday).

Return the last day of d's week (UTC), 6 days after `start-of-week`.
`fdow` defaults to 0 (Sunday → Saturday).
sourceraw docstring

in-range?cljs

(in-range? d a b)

True if d is between a and b inclusive (either order).

True if d is between a and b inclusive (either order).
sourceraw docstring

iso->datecljs

(iso->date s)

"YYYY-MM-DD" → JS Date at UTC midnight, or nil on parse failure.

"YYYY-MM-DD" → JS Date at UTC midnight, or nil on parse failure.
sourceraw docstring

iso-week-numbercljs

(iso-week-number d)

ISO-8601 week number (1-53) for d's UTC date. Weeks start Monday; week 1 is the week containing the first Thursday of the year.

ISO-8601 week number (1-53) for d's UTC date. Weeks start Monday; week 1
is the week containing the first Thursday of the year.
sourceraw docstring

max-datecljs

(max-date a b)
source

min-datecljs

(min-date a b)
source

month-gridcljs

(month-grid d)
(month-grid d fdow)

Return a 42-item vector for a calendar view of the month containing d. Each entry is {:date jsDate :in-month? boolean}. fdow is the first day of the week (0=Sunday..6=Saturday); defaults to 0 (Sunday).

Return a 42-item vector for a calendar view of the month containing d.
Each entry is {:date jsDate :in-month? boolean}. `fdow` is the first
day of the week (0=Sunday..6=Saturday); defaults to 0 (Sunday).
sourceraw docstring

pad2cljs

(pad2 n)

Zero-pad integer n to 2 digits.

Zero-pad integer n to 2 digits.
sourceraw docstring

start-of-monthcljs

(start-of-month d)

Return UTC midnight on the 1st of d's month.

Return UTC midnight on the 1st of d's month.
sourceraw docstring

start-of-weekcljs

(start-of-week d)
(start-of-week d fdow)

Return the start of d's week (UTC). fdow is the first day of the week (0=Sunday..6=Saturday); defaults to 0 (Sunday).

Return the start of d's week (UTC). `fdow` is the first day of the week
(0=Sunday..6=Saturday); defaults to 0 (Sunday).
sourceraw docstring

weekday-0-suncljs

(weekday-0-sun d)

Day of week 0=Sunday..6=Saturday for d's UTC date.

Day of week 0=Sunday..6=Saturday for d's UTC date.
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