Liking cljdoc? Tell your friends :D

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

A common set of date/time functions for CLJC. These functions give client-server agreement on dealing with common date/time processing that happens with respect to UI controls. There is a general formatting function that uses Java DateTimeFormatter on the JVM for server-side, but in order to keep the UI code a light as possible that formatter is hand-written using the built-in browser Intl function (which has the locale data for many locales and does not bloat your js file).

As such the formatter from this namespace is not completely isomophic in CLJ vs CLJS, since in CLJ that formatter can be used for general parsing, but in CLJS it cannot. This should not generally be a problem because the parsing you usually need in the UI is for date controls, and there are functions for ISO parsing that work just fine without needing locale data.

A common set of date/time functions for CLJC. These functions give client-server agreement on dealing with common
date/time processing that happens with respect to UI controls. There is a general formatting function that uses
Java DateTimeFormatter on the JVM for server-side, but in order to keep the UI code a light as possible that formatter
is hand-written using the built-in browser Intl function (which has the locale data for many locales and does not
bloat your js file).

As such the `formatter` from this namespace is not completely isomophic in CLJ vs CLJS, since in CLJ that formatter
can be used for general parsing, but in CLJS it cannot. This should not generally be a problem because the parsing
you usually need in the UI is for date controls, and there are functions for ISO parsing that work just fine without
needing locale data.
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≠

clj
(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.

NOTE: In CLJS this generates a formatter that uses Intl, and IS NOT a java-time DateTimeFormatter. This means you CANNOT use it for parsing. If you need parsing, you must add a js-joda locale to your deps and use cljc.java-time directly, or come up with some other solution.

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.

NOTE: In CLJS this generates a formatter that uses Intl, and IS NOT a java-time DateTimeFormatter. This means
you CANNOT use it for parsing. If you need parsing, you must add a js-joda locale to your deps and use cljc.java-time
directly, or come up with some other solution.
cljs
(formatter f)
(formatter f l)
source (clj)source (cljs)raw 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.

Convert an HTML date input string to an inst at the given local time, adjusted to the correct *current-timezone*.
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

max-instclj/s

(max-inst & insts)

Returns the maximum inst from a list of insts. Returns nil if no insts are passed.

Returns the maximum inst from a list of insts. Returns nil if no insts are passed.
sourceraw docstring

min-instclj/s

(min-inst & insts)

Returns the minimum inst from a list of insts. Returns nil if no insts are passed.

Returns the minimum inst from a list of insts. Returns nil if no insts are passed.
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≠

clj
(tformat format inst)
cljs
(tformat f inst)
source (clj)source (cljs)

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