timex v3.5.0 Timex.Parse.DateTime.Parser View Source

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

Link to this function

parse(date_string, format_string) View Source
parse(binary(), binary()) ::
  {:ok, DateTime.t() | NaiveDateTime.t()} | {:error, term()}

Parses a date/time string using the default parser.

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"
Link to this function

parse(date_string, format_string, tokenizer) View Source
parse(binary(), binary(), atom()) ::
  {:ok, DateTime.t() | NaiveDateTime.t()} | {:error, term()}

Parses a date/time string using the provided tokenizer. Tokenizers must implement the Timex.Parse.DateTime.Tokenizer behaviour.

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/GMT+2"
Link to this function

parse!(date_string, format_string, tokenizer \\ Default) View Source
parse!(String.t(), String.t(), atom() | nil) ::
  DateTime.t() | NaiveDateTime.t() | no_return()

Same as parse/2 and parse/3, but raises on error.