timex v2.0.0 Timex.Format.DateTime.Formatter behaviour
This module defines the behaviour for custom DateTime formatters.
Summary
Functions
Formats a DateTime struct as a string, using the provided format
string and formatter. If a formatter is not provided, the formatter
used is Timex.DateFormat.Formatters.DefaultFormatter
Formats a DateTime struct as a string, using the provided format
string and formatter. If a formatter is not provided, the formatter
used is Timex.DateFormat.Formatters.DefaultFormatter
Given a token (as found in Timex.Parsers.Directive
), and a DateTime struct,
produce a string representation of the token using values from the struct
Validates the provided format string, using the provided formatter,
or if none is provided, the default formatter. Returns :ok
when valid,
or {:error, reason}
if not valid
Functions
Specs
format(Timex.Date.t | Timex.DateTime.t, String.t, atom | nil) ::
{:ok, String.t} |
{:error, term}
Formats a DateTime struct as a string, using the provided format
string and formatter. If a formatter is not provided, the formatter
used is Timex.DateFormat.Formatters.DefaultFormatter
.
Specs
format!(Timex.Date.t | Timex.DateTime.t, String.t, atom | nil) ::
String.t |
no_return
Formats a DateTime struct as a string, using the provided format
string and formatter. If a formatter is not provided, the formatter
used is Timex.DateFormat.Formatters.DefaultFormatter
.
If an error is encountered during formatting, format!
will raise.
Specs
format_token(atom, Timex.Date.t | Timex.DateTime.t, list, list, list) ::
String.t |
{:error, term}
Given a token (as found in Timex.Parsers.Directive
), and a DateTime struct,
produce a string representation of the token using values from the struct.
Specs
validate(String.t, atom | nil) ::
:ok |
{:error, term}
Validates the provided format string, using the provided formatter,
or if none is provided, the default formatter. Returns :ok
when valid,
or {:error, reason}
if not valid.
Callbacks
Specs
format(date :: Timex.DateTime.t, format_string :: String.t) ::
{:ok, String.t} |
{:error, term}
Specs
format!(date :: Timex.DateTime.t, format_string :: String.t) ::
String.t |
no_return
Specs
tokenize(format_string :: String.t) ::
{:ok, [Timex.Parse.DateTime.Tokenizers.Directive.t]} |
{:error, term}