Liking cljdoc? Tell your friends :D

com.fulcrologic.rad.type-support.date-time

A common set of date/time functions for CLJC. Libraries like tick are promising, and CLJC time is useful (and used by this ns), but cljc-time does not have an interface that is the same between the two languages, and tick is alpha (and often annoying).

A common set of date/time functions for CLJC.  Libraries like `tick` are promising, and CLJC time is useful
(and used by this ns), but cljc-time does not have an interface that is the same between the two languages,
and tick is alpha (and often annoying).
raw docstring

*current-timezone*clj/s≠

clj

The current time zone for all date time operations. Defaults to nil. Should be set using set-timezone! in cljs, and should be thread-bound to a processing request using binding in CLJ. The value of this var is a java.time.ZoneId, which can be obtained from a string with cljc.time.zone-id/of.

The current time zone for all date time operations. Defaults to nil. Should be set using
`set-timezone!` in cljs, and should be thread-bound to a processing request using `binding` in CLJ.
The value of this var is a java.time.ZoneId, which can be obtained from a string with cljc.time.zone-id/of.
source (clj)source (cljs)raw docstring

*current-zone-name*clj/s≠

clj

The current time zone for all date time operations. Defaults to nil. Should be set using set-timezone! in cljs, and should be thread-bound to a processing request using binding in CLJ. The value of this var is a java.time.ZoneId, which can be obtained from a string with cljc.time.zone-id/of.

The current time zone for all date time operations. Defaults to nil. Should be set using
`set-timezone!` in cljs, and should be thread-bound to a processing request using `binding` in CLJ.
The value of this var is a java.time.ZoneId, which can be obtained from a string with cljc.time.zone-id/of.
source (clj)source (cljs)raw docstring

beginning-of-dayclj/s

(beginning-of-day)
(beginning-of-day inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the day of the input instant (which defaults to now).

Returns an inst? that is adjusted to midnight (local time of current time zone) on the day of the
input instant (which defaults to `now`).
sourceraw docstring

beginning-of-monthclj/s

(beginning-of-month)
(beginning-of-month inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of the month of the input instant (which defaults to now).

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of the month of the
input instant (which defaults to `now`).
sourceraw docstring

beginning-of-yearclj/s

(beginning-of-year)
(beginning-of-year inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of January in this year.

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of January in this
year.
sourceraw docstring

date-time?clj/s

source

date?clj/s

source

end-of-dayclj/s

(end-of-day)
(end-of-day inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the next day of the input instant (which defaults to now). This creates an open interval for end.

Returns an inst? that is adjusted to midnight (local time of current time zone) on the next day of the
input instant (which defaults to `now`). This creates an open interval for end.
sourceraw docstring

end-of-monthclj/s

(end-of-month)
(end-of-month inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of the next month of the input instant (which defaults to now). This creates an open interval for end.

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of the next month of the
input instant (which defaults to `now`). This creates an open interval for end.
sourceraw docstring

end-of-yearclj/s

(end-of-year)
(end-of-year inst)

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of January in the next year.

Returns an inst? that is adjusted to midnight (local time of current time zone) on the first day of January in the
next year.
sourceraw docstring

formatterclj/s

(formatter fmt)
(formatter fmt locale)

Constructs a DateTimeFormatter out of either a

  • format string - "YYYY/mm/DD" "YYY HH:MM" etc. or
  • formatter name - :iso-instant :iso-local-date etc

and a Locale, which is optional.

Constructs a DateTimeFormatter out of either a
* format string - "YYYY/mm/DD" "YYY HH:MM" etc.
or
* formatter name - :iso-instant :iso-local-date etc

and a Locale, which is optional.
sourceraw docstring

get-zone-idclj/s

(get-zone-id zone-name)

Returns the ZoneID of zone-name, or current-timezone if zone-name is nil.

Returns the ZoneID of zone-name, or *current-timezone* if zone-name is nil.
sourceraw docstring

html-date->instclj/s

(html-date->inst html-date local-time)

Convert an HTML date input string to an inst at the given local time, adjusted to the correct current-timezone. Returns now if the string isn't a proper ISO string.

Convert an HTML date input string to an inst at the given local time, adjusted to the correct *current-timezone*. Returns
`now` if the string isn't a proper ISO string.
sourceraw docstring

html-date-string->local-dateclj/s

(html-date-string->local-date s)

Convert a standard HTML5 date input string to a local date

Convert a standard HTML5 date input string to a local date
sourceraw docstring

html-datetime-string->instclj/s

(html-datetime-string->inst date-time-string)
(html-datetime-string->inst zone-name date-time-string)
source

inst->html-dateclj/s

(inst->html-date inst)

Convert an inst to an HTML date input string. Assumes current-timezone. Always returns a string. Will return today's date if inst is nil or otherwise fails to convert.

Convert an inst to an HTML date input string. Assumes *current-timezone*. Always returns a string. Will return
today's date if inst is nil or otherwise fails to convert.
sourceraw docstring

inst->html-datetime-stringclj/s

(inst->html-datetime-string inst)
(inst->html-datetime-string zone-name inst)
source

inst->human-readable-dateclj/s

(inst->human-readable-date inst)

Converts a UTC Instant into the correctly-offset and human-readable (e.g. America/Los_Angeles) date string.

Uses locale from locale/current-locale.

Converts a UTC Instant into the correctly-offset and human-readable (e.g. America/Los_Angeles) date string.

Uses locale from `locale/current-locale`.
sourceraw docstring

inst->instantclj/s

(inst->instant i)
source

inst->local-dateclj/s

(inst->local-date inst)
(inst->local-date zone-name inst)

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) LocalDate.

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) LocalDate.
sourceraw docstring

inst->local-datetimeclj/s

(inst->local-datetime inst)
(inst->local-datetime zone-name inst)

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) LocalDateTime.

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) LocalDateTime.
sourceraw docstring

inst->zoned-date-timeclj/s

(inst->zoned-date-time inst)
(inst->zoned-date-time zone-name inst)

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) ZonedDateTime.

Converts a UTC Instant into the correctly-offset (e.g. America/Los_Angeles) ZonedDateTime.
sourceraw docstring

instant->instclj/s

(instant->inst i)
source

local-date->html-date-stringclj/s

(local-date->html-date-string d)

Convert a standard HTML5 date input string to a local date

Convert a standard HTML5 date input string to a local date
sourceraw docstring

local-date->instclj/s

(local-date->inst local-dt)
(local-date->inst zone-name local-dt)
(local-date->inst zone-name month day yyyy)

Returns a UTC Clojure inst based on the date given as time in the named (ISO) zone (e.g. America/Los_Angeles). If no zone name (or nil) is given, then the *current-timezone* will be used.

Returns a UTC Clojure inst based on the date given as time in the named (ISO) zone (e.g. America/Los_Angeles).
If no zone name (or nil) is given, then the `*current-timezone*` will be used.
sourceraw docstring

local-datetime->instclj/s

(local-datetime->inst local-dt)
(local-datetime->inst zone-name local-dt)
(local-datetime->inst zone-name month day yyyy hh mm)
(local-datetime->inst zone-name month day yyyy hh mm ss)

Returns a UTC Clojure inst based on the date/time given as time in the named (ISO) zone (e.g. America/Los_Angeles). If no zone name (or nil) is given, then the *current-timezone* will be used.

Returns a UTC Clojure inst based on the date/time given as time in the named (ISO) zone (e.g. America/Los_Angeles).
If no zone name (or nil) is given, then the `*current-timezone*` will be used.
sourceraw docstring

mon-to-sundayclj/s

source

new-dateclj/s

(new-date)
(new-date millis)

Create a Date object from milliseconds (defaults to now).

Create a Date object from milliseconds (defaults to now).
sourceraw docstring

nowclj/s

(now)

Returns the current time as an inst.

Returns the current time as an inst.
sourceraw docstring

now-msclj/s

(now-ms)

Returns the current time in ms.

Returns the current time in ms.
sourceraw docstring

set-timezone!clj/s

(set-timezone! zone-name)

Set the root binding of timezone, a dynamic var. In CLJS there is a lot of async behavior, but the overall time zone is typically fixed for a user. In CLJ the timezone usually needs to be bound to the local processing thread for a request. Therefore, the typical CLJS code will call this function on start, and the typical CLJ code will do a (binding [*current-timezone* (z/of user-zone)] ...).

Set the root binding of timezone, a dynamic var. In CLJS there is a lot of async behavior, but the overall
time zone is typically fixed for a user. In CLJ the timezone usually needs to be bound to the local processing
thread for a request. Therefore, the typical CLJS code will call this function on start, and the typical
CLJ code will do a `(binding [*current-timezone* (z/of user-zone)] ...)`. 
sourceraw docstring

tformatclj/s

(tformat format inst)
source

with-timezoneclj/smacro

(with-timezone zone-name & body)

Set the (thread-local) "current time zone"to the given zone-name (a string zone id) for the duration of the rest of the body. Simply a short-hand for (binding [*current-timezone* (zone-id/of zone-name)] ...).

Set the (thread-local) "current time zone"to the given `zone-name` (a string zone id) for the duration of the rest of the
`body`. Simply a short-hand for `(binding [*current-timezone* (zone-id/of zone-name)] ...)`.
sourceraw docstring

zone-region?clj/s

source

zoned-date-time->instclj/s

(zoned-date-time->inst ztm)

Convert a zoned-date-time back to a low-level inst?

Convert a zoned-date-time back to a low-level inst?
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close