Liking cljdoc? Tell your friends :D

cljs-time.coerce

Utilites to coerce goog.data DateTime instances to and from

various other types.

For example, to convert a goog.date DateTime to and from a js number:

=> (to-long (date-time 1998 4 25)) 893462400000

=> (from-long 893462400000) #<19980425T000000>

### Utilites to coerce goog.data DateTime instances to and from
various other types.

For example, to convert a goog.date DateTime to and from a js number:

  => (to-long (date-time 1998 4 25))
  893462400000

  => (from-long 893462400000)
  #<19980425T000000>
raw docstring

cljs-time.core

The core namespace for date-time operations in the cljs-time library.

Create a DateTime instance with date-time (or a local DateTime instance with local-date-time), specifying the year, month, day, hour, minute, second, and millisecond:

=> (date-time 1986 10 14 4 3 27 456) #<DateTime 1986-10-14T04:03:27.456Z>

=> (local-date-time 1986 10 14 4 3 27 456) #<DateTime 1986-10-14T04:03:27.456>

Less-significant fields can be omitted:

=> (date-time 1986 10 14) #<DateTime 1986-10-14T00:00:00.000Z>

=> (local-date-time 1986 10 14) #<DateTime 1986-10-14T00:00:00.000>

Get the current time with (now) and the start of the Unix epoch with (epoch).

Once you have a date-time, use accessors like hour and second to access the corresponding fields:

=> (hour (date-time 1986 10 14 22)) 22

=> (hour (local-date-time 1986 10 14 22)) 22

The functions after? and before? determine the relative position of two DateTime instances:

=> (after? (date-time 1986 10) (date-time 1986 9)) true

=> (after? (local-date-time 1986 10) (local-date-time 1986 9)) true

Often you will want to find a date some amount of time from a given date. For example, to find the time 1 month and 3 weeks from a given date-time:

=> (plus (date-time 1986 10 14) (months 1) (weeks 3)) #<DateTime 1986-12-05T00:00:00.000Z>

=> (plus (local-date-time 1986 10 14) (months 1) (weeks 3)) #<DateTime 1986-12-05T00:00:00.000Z>

An Interval is used to represent the span of time between two DateTime instances. Construct one using interval, then query them using within?, overlaps?, and abuts?

=> (within? (interval (date-time 1986) (date-time 1990)) (date-time 1987)) true

To find the amount of time encompased by an interval, use in-seconds and in-minutes:

=> (in-minutes (interval (date-time 1986 10 2) (date-time 1986 10 14))) 17280

Note that all functions in this namespace work with Joda objects or ints. If you need to print or parse date-times, see cljs-time.format. If you need to ceorce date-times to or from other types, see cljs-time.coerce.

### The core namespace for date-time operations in the cljs-time library.

Create a DateTime instance with date-time (or a local DateTime instance with local-date-time),
specifying the year, month, day, hour, minute, second, and millisecond:

  => (date-time 1986 10 14 4 3 27 456)
  #<DateTime 1986-10-14T04:03:27.456Z>

  => (local-date-time 1986 10 14 4 3 27 456)
  #<DateTime 1986-10-14T04:03:27.456>

Less-significant fields can be omitted:

  => (date-time 1986 10 14)
  #<DateTime 1986-10-14T00:00:00.000Z>

  => (local-date-time 1986 10 14)
  #<DateTime 1986-10-14T00:00:00.000>

Get the current time with (now) and the start of the Unix epoch with (epoch).

Once you have a date-time, use accessors like hour and second to access the
corresponding fields:

  => (hour (date-time 1986 10 14 22))
  22

  => (hour (local-date-time 1986 10 14 22))
  22

The functions after? and before? determine the relative position of two
DateTime instances:

  => (after? (date-time 1986 10) (date-time 1986 9))
  true

  => (after? (local-date-time 1986 10) (local-date-time 1986 9))
  true

Often you will want to find a date some amount of time from a given date. For
example, to find the time 1 month and 3 weeks from a given date-time:

  => (plus (date-time 1986 10 14) (months 1) (weeks 3))
  #<DateTime 1986-12-05T00:00:00.000Z>

  => (plus (local-date-time 1986 10 14) (months 1) (weeks 3))
  #<DateTime 1986-12-05T00:00:00.000Z>

An Interval is used to represent the span of time between two DateTime
instances. Construct one using interval, then query them using within?,
overlaps?, and abuts?

  => (within? (interval (date-time 1986) (date-time 1990)) (date-time 1987))
  true

To find the amount of time encompased by an interval, use in-seconds and
in-minutes:

  => (in-minutes (interval (date-time 1986 10 2) (date-time 1986 10 14)))
  17280

Note that all functions in this namespace work with Joda objects or ints. If
you need to print or parse date-times, see cljs-time.format. If you need to
ceorce date-times to or from other types, see cljs-time.coerce.
raw docstring

cljs-time.extend

Optional namespace to extend goog.date.* DateTime types

Equality of goog.date.* DateTime types works differently to clj-time/Joda's equality. Optionally require this namespace to extend cljs.core/IEquiv protocol for:

  • goog.date.Date
  • goog.date.DateTime
  • goog.date.UtcDateTime
### Optional namespace to extend goog.date.* DateTime types

Equality of goog.date.* DateTime types works differently to
clj-time/Joda's equality. Optionally require this namespace
to extend cljs.core/IEquiv protocol for:

 * goog.date.Date
 * goog.date.DateTime
 * goog.date.UtcDateTime
raw docstring

No vars found in this namespace.

cljs-time.format

Utilities for parsing and unparsing DateTimes as Strings.

Parsing and printing are controlled by formatters. You can either use one of the built in ISO 8601 and a single RFC 822 formatters or define your own, e.g.:

(def built-in-formatter (formatters :basic-date-time)) (def custom-formatter (formatter "yyyyMMdd"))

To see a list of available built-in formatters and an example of a date-time printed in their format:

(show-formatters)

Once you have a formatter, parsing and printing are strait-forward:

=> (parse custom-formatter "20100311") #<DateTime 2010-03-11T00:00:00.000Z>

=> (unparse custom-formatter (date-time 2010 10 3)) "20101003"

By default the parse function always returns a DateTime instance with a UTC time zone, and the unparse function always represents a given DateTime instance in UTC. A formatter can be modified to different timezones, locales, etc with the functions with-zone, with-locale, with-chronology, and with-pivot-year.

### Utilities for parsing and unparsing DateTimes as Strings.

Parsing and printing are controlled by formatters. You can either use one
of the built in ISO 8601 and a single RFC 822 formatters or define your own, e.g.:

  (def built-in-formatter (formatters :basic-date-time))
  (def custom-formatter (formatter "yyyyMMdd"))

To see a list of available built-in formatters and an example of a date-time
printed in their format:

  (show-formatters)

Once you have a formatter, parsing and printing are strait-forward:

  => (parse custom-formatter "20100311")
  #<DateTime 2010-03-11T00:00:00.000Z>

  => (unparse custom-formatter (date-time 2010 10 3))
  "20101003"

By default the parse function always returns a DateTime instance with a UTC
time zone, and the unparse function always represents a given DateTime
instance in UTC. A formatter can be modified to different timezones, locales,
etc with the functions with-zone, with-locale, with-chronology, and
with-pivot-year.
raw docstring

cljs-time.instant

No vars found in this namespace.

cljs-time.local

Functions for working with local time without having to shift to/from utc, the preferred time zone of clj-time.core. Get the current local time with (local-now). (to-local-date-time obj) returns a local date-time instance retaining the time fields. The following all return 1986-10-14 04:03:27.246 with the local time zone. (to-local-date-time (clj-time.core/date-time 1986 10 14 4 3 27 246)) (to-local-date-time "1986-10-14T04:03:27.246") (to-local-date-time "1986-10-14T04:03:27.246Z") The dynamic var local-formatters contains a map of local formatters for parsing and printing. It is initialized with all the formatters in clj-time.format localized. to-local-date-time for strings uses local-formatters to parse. (format-local-time (local-now) :basic-date-time) formats an obj using a formatter in local-formatters corresponding to the format-key passed in.

Functions for working with local time without having to shift
to/from utc, the preferred time zone of clj-time.core.
Get the current local time with (local-now).
(to-local-date-time obj) returns a local date-time instance
retaining the time fields.
The following all return 1986-10-14 04:03:27.246 with the
local time zone.
(to-local-date-time (clj-time.core/date-time 1986 10 14 4 3 27 246))
(to-local-date-time "1986-10-14T04:03:27.246")
(to-local-date-time "1986-10-14T04:03:27.246Z")
The dynamic var *local-formatters* contains a map of local formatters
for parsing and printing. It is initialized with all the formatters in
clj-time.format localized.
to-local-date-time for strings uses *local-formatters* to parse.
(format-local-time (local-now) :basic-date-time) formats an obj using
a formatter in *local-formatters* corresponding to the format-key
passed in.
raw docstring

cljs-time.predicates

Predicate functions to ask basic questions about a date.

Was it Monday? (monday? (clj-time.core/date-time 1999 9 9))

Is it January? (january? (clj-time.core/date-time 2011 1 1))

### Predicate functions to ask basic questions about a date.

Was it Monday?
(monday? (clj-time.core/date-time 1999 9 9))

Is it January?
(january? (clj-time.core/date-time 2011 1 1))
raw docstring

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

× close