View Source Timex.Parse.DateTime.Parser (timex v3.7.11)
This is the base plugin behavior for all Timex date/time string parsers.
Link to this section Summary
Functions
Parses a date/time string using the default parser.
Parses a date/time string using the provided tokenizer. Tokenizers must implement the
Timex.Parse.DateTime.Tokenizer
behaviour.
Link to this section Functions
@spec parse!(String.t(), String.t(), atom() | nil) :: DateTime.t() | NaiveDateTime.t() | Timex.AmbiguousDateTime.t() | no_return()
@spec parse(binary(), binary()) :: {:ok, DateTime.t() | NaiveDateTime.t() | Timex.AmbiguousDateTime.t()} | {:error, term()}
Parses a date/time string using the default parser.
examples
Examples
iex> use Timex
...> {:ok, dt} = Elixir.Timex.Parse.DateTime.Parser.parse("2014-07-29T00:20:41.196Z", "{ISO:Extended:Z}")
...> dt.year
2014
iex> dt.month
7
iex> dt.day
29
iex> dt.time_zone
"Etc/UTC"
@spec parse(binary(), binary(), atom()) :: {:ok, DateTime.t() | NaiveDateTime.t() | Timex.AmbiguousDateTime.t()} | {:error, term()}
Parses a date/time string using the provided tokenizer. Tokenizers must implement the
Timex.Parse.DateTime.Tokenizer
behaviour.
examples
Examples
iex> use Timex
...> {:ok, dt} = Elixir.Timex.Parse.DateTime.Parser.parse("2014-07-29T00:30:41.196-02:00", "{ISO:Extended}", Timex.Parse.DateTime.Tokenizers.Default)
...> dt.year
2014
iex> dt.month
7
iex> dt.day
29
iex> dt.time_zone
"Etc/UTC-2"