Timex.DateFormat
Date formatting and parsing.
This module provides an interface and core implementation for converting date values into strings (formatting) or the other way around (parsing) according to the specified template.
Multiple template formats are supported, each one provided by a separate module. One can also implement custom formatters for use with this module.
Summary↑
format!(date, format_string) | Raising version of |
format!(date, format_string, formatter) | Raising version of |
format(date, format_string) | Converts date values to strings according to the given template (aka format string) |
format(date, format_string, formatter) | Same as |
parse!(date_string, format_string) | Raising version of |
parse!(date_string, format_string, parser) | Raising version of |
parse(date_string, format_string) | Parses the date encoded in |
parse(date_string, format_string, parser) | Parses the date encoded in |
validate(format_string) | Verifies the validity of the given format string. The default formatter is assumed |
validate(format_string, formatter) | Verifies the validity of the given format string according to the provided formatter |
Functions
Specs:
- format(%Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}, String.t) :: {:ok, String.t} | {:error, String.t}
Converts date values to strings according to the given template (aka format string).
Specs:
- format(%Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}, String.t, atom) :: {:ok, String.t} | {:error, String.t}
Same as format/2
, but takes a custom formatter.
Specs:
- format!(%Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}, String.t) :: String.t | no_return
Raising version of format/2
. Returns a string with formatted date or raises a FormatError
.
Specs:
- format!(%Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}, String.t, atom) :: String.t | no_return
Raising version of format/3
. Returns a string with formatted date or raises a FormatError
.
Specs:
- parse(String.t, String.t) :: {:ok, %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}} | {:error, term}
Parses the date encoded in string
according to the template.
Specs:
- parse(String.t, String.t, atom) :: {:ok, %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}} | {:error, term}
Parses the date encoded in string
according to the template by using the
provided formatter.
Specs:
- parse!(String.t, String.t) :: %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term} | no_return
Raising version of parse/2
. Returns a DateTime struct, or raises a ParseError
.
Specs:
- parse!(String.t, String.t, atom) :: %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term} | no_return
Raising version of parse/3
. Returns a DateTime struct, or raises a ParseError
.
Specs:
- validate(String.t) :: :ok | {:error, term}
Verifies the validity of the given format string. The default formatter is assumed.
Returns :ok
if the format string is clean, { :error, <reason> }
otherwise.
Specs:
- validate(String.t, atom) :: :ok | {:error, term}
Verifies the validity of the given format string according to the provided formatter.
Returns :ok
if the format string is clean, { :error, <reason> }
otherwise.