7.7
15 Formatting and Parsing
15.1 Formatting Dates and Times
Formats
t using the given
pattern
. The
pattern syntax
is specified by CLDR.
Examples:
|
Sat, November 12, 1955 AD | Sat 2:42 AM |
|
|
sam. 12 nov. 1955 ap. J.-C. | sam. 2:42:30 AM |
|
15.2 Parsing Dates and Times
15.2.1 Parsing ISO 8601 representations
Parses an ISO 8601 representation of a date into a
date. Note that the input must
use the ISO 8601
extended format.
Examples:
Parses an ISO 8601 representation of a time into a
time. Note that the input must
use the ISO 8601
extended format.
Example:
Parses an ISO 8601 combined date and time representation into a
datetime. Note that
the input must use the ISO 8601
extended format.
Example:
Parses an ISO 8601 combined date and time representation into a
moment. Note that
the input must use the ISO 8601
extended format.
Example:
> (iso8601->moment "2014-03-20T19:20:09.3045Z") |
#<moment 2014-03-20T19:20:09.3045Z> |
Parses a non-standard format, consisting of an ISO 8601 combined date and time representation
and an IANA time zone ID in brackets, into a
moment. The input format is the same
as that produced by
moment->iso8601/tzid. Note that the ISO 8601 portion of
the input must use the ISO 8601
extended format.
Example:
> (iso8601/tzid->moment "2014-03-20T19:20:09.3045-04:00[America/New_York]") |
#<moment 2014-03-20T19:20:09.3045-04:00[America/New_York]> |
15.2.2 Flexible parsing based on patterns
Example:
|
'(#<date 1977-01-24> #<date 2015-03-15>) |
Example:
|
'(#<time 00:00:00> #<time 02:02:02>) |
Example:
|
'(#<datetime 1977-01-24T00:00:00> #<datetime 2015-03-15T02:02:02>) |
Parses
str according to
pattern, which uses the CLDR
pattern syntax.
The result is returned as a
moment. If the input cannot be parsed as a
moment,
exn:gregor:parse is raised. If the result’s UTC offset is ambigous,
resolve
is used to resolve the ambiguity.
Example:
|
'(#<moment 1977-01-24T00:00:00-10:00[Pacific/Honolulu]> | #<moment 2015-03-15T02:02:02-04:00>) |
|
A parameter used to control how parsed two-digit years are resolved into complete years.
The default implementation is:
Example: