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.
(formatter fmts)
(formatter fmts dtz)
Returns a custom formatter for the given date-time pattern.
Returns a custom formatter for the given date-time pattern.
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.
(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.
(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.
(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.
(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.
(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.
(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.
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close