Liking cljdoc? Tell your friends :D

clj-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 straightforward:

=> (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, with-default-year 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 straightforward:

  => (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,
with-default-year and with-pivot-year.
raw docstring

formatterclj

(formatter fmts)
(formatter fmts dtz)
(formatter dtz fmts & more)

Returns a custom formatter for the given date-time pattern or keyword.

Returns a custom formatter for the given date-time pattern or keyword.
sourceraw docstring

formatter-localclj

(formatter-local fmt)

Returns a custom formatter with no time zone info.

Returns a custom formatter with no time zone info.
sourceraw docstring

formattersclj

Map of ISO 8601 and a single RFC 822 formatters that can be used for parsing and, in most cases, printing.

Map of ISO 8601 and a single RFC 822 formatters that can be used for parsing and, in most
cases, printing.
sourceraw docstring

Mappablecljprotocol

instant->mapclj

(instant->map instant)

Returns a map representation of the given instant. It will contain the following keys: :years, :months, :days, :hours, :minutes and :seconds.

Returns a map representation of the given instant.
It will contain the following keys: :years, :months,
:days, :hours, :minutes and :seconds.
source

parseclj

(parse s)
(parse fmt s)

Returns a DateTime instance in the UTC time zone obtained by parsing the given string according to the given formatter.

Returns a DateTime instance in the UTC time zone obtained by parsing the
given string according to the given formatter.
sourceraw docstring

parse-localclj

(parse-local s)
(parse-local fmt s)

Returns a LocalDateTime instance obtained by parsing the given string according to the given formatter.

Returns a LocalDateTime instance obtained by parsing the
given string according to the given formatter.
sourceraw docstring

parse-local-dateclj

(parse-local-date s)
(parse-local-date fmt s)

Returns a LocalDate instance obtained by parsing the given string according to the given formatter.

Returns a LocalDate instance obtained by parsing the
given string according to the given formatter.
sourceraw docstring

parse-local-timeclj

(parse-local-time s)
(parse-local-time fmt s)

Returns a LocalTime instance obtained by parsing the given string according to the given formatter.

Returns a LocalTime instance obtained by parsing the
given string according to the given formatter.
sourceraw docstring

show-formattersclj

(show-formatters)
(show-formatters dt)

Shows how a given DateTime, or by default the current time, would be formatted with each of the available printing formatters.

Shows how a given DateTime, or by default the current time, would be
formatted with each of the available printing formatters.
sourceraw docstring

unparseclj

(unparse fmt dt)

Returns a string representing the given DateTime instance in UTC and in the form determined by the given formatter.

Returns a string representing the given DateTime instance in UTC and in the
form determined by the given formatter.
sourceraw docstring

unparse-localclj

(unparse-local fmt dt)

Returns a string representing the given LocalDateTime instance in the form determined by the given formatter.

Returns a string representing the given LocalDateTime instance in the
form determined by the given formatter.
sourceraw docstring

unparse-local-dateclj

(unparse-local-date fmt ld)

Returns a string representing the given LocalDate instance in the form determined by the given formatter.

Returns a string representing the given LocalDate instance in the form
determined by the given formatter.
sourceraw docstring

unparse-local-timeclj

(unparse-local-time fmt lt)

Returns a string representing the given LocalTime instance in the form determined by the given formatter.

Returns a string representing the given LocalTime instance in the form
determined by the given formatter.
sourceraw docstring

with-chronologyclj

(with-chronology f c)

Return a copy of a formatter that uses the given Chronology.

Return a copy of a formatter that uses the given Chronology.
sourceraw docstring

with-default-yearclj

(with-default-year f default-year)

Return a copy of a formatter that uses the given default year.

Return a copy of a formatter that uses the given default year.
sourceraw docstring

with-localeclj

(with-locale f l)

Return a copy of a formatter that uses the given Locale.

Return a copy of a formatter that uses the given Locale.
sourceraw docstring

with-pivot-yearclj

(with-pivot-year f pivot-year)

Return a copy of a formatter that uses the given pivot year.

Return a copy of a formatter that uses the given pivot year.
sourceraw docstring

with-zoneclj

(with-zone f dtz)

Return a copy of a formatter that uses the given DateTimeZone.

Return a copy of a formatter that uses the given DateTimeZone.
sourceraw docstring

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

× close