Calendar v1.0.0 Calendar.Date.Parse View Source
Link to this section Summary
Functions
Parses ISO 8601 date strings.
Parses ISO 8601 date strings.
Parses ISO 8601 week date strings.
Parses ISO 8601 week date strings. Like iso_week_date/1 But returns the the result untagged and raises in case of an error.
Link to this section Functions
Link to this function
iso8601(string) View Source
Parses ISO 8601 date strings.
The function accepts both the extended and the basic format.
Examples
# Extended format
iex> iso8601("2016-01-05")
{:ok, %Date{year: 2016, month: 1, day: 5}}
# Basic format (the basic format does not have dashes)
iex> iso8601("20160105")
{:ok, %Date{year: 2016, month: 1, day: 5}}
iex> iso8601("2016-99-05")
{:error, :invalid_date}
Link to this function
iso8601!(string) View Source
Parses ISO 8601 date strings.
Like iso8601/1
, but returns the result untagged and raises
in case of an error.
Examples
# Extended format
iex> iso8601!("2016-01-05")
%Date{year: 2016, month: 1, day: 5}
Link to this function
iso_week_date(string) View Source
Parses ISO 8601 week date strings.
Examples
iex> iso_week_date("2004-W53-6")
{:ok, %Date{year: 2005, month: 1, day: 1}}
iex> iso_week_date("2008-W01-2")
{:ok, %Date{year: 2008, month: 1, day: 1}}
iex> iso_week_date("2004-W53-6D")
{:ok, %Date{year: 2005, month: 1, day: 1}}
iex> iso_week_date("2004-W53-9")
:error
iex> iso_week_date("2004-W54-9")
:error
iex> iso_week_date("2004-W0-9")
:error
Link to this function
iso_week_date!(string) View Source
Parses ISO 8601 week date strings. Like iso_week_date/1 But returns the the result untagged and raises in case of an error.
Examples
iex> iso_week_date!("2004-W53-6")
%Date{year: 2005, month: 1, day: 1}