Date.new
You're seeing just the function
new
, go back to Date module for more information.
Specs
new(Calendar.year(), Calendar.month(), Calendar.day(), Calendar.calendar()) :: {:ok, t()} | {:error, atom()}
Builds a new ISO date.
Expects all values to be integers. Returns {:ok, date}
if each
entry fits its appropriate range, returns {:error, reason}
otherwise.
Examples
iex> Date.new(2000, 1, 1)
{:ok, ~D[2000-01-01]}
iex> Date.new(2000, 13, 1)
{:error, :invalid_date}
iex> Date.new(2000, 2, 29)
{:ok, ~D[2000-02-29]}
iex> Date.new(2000, 2, 30)
{:error, :invalid_date}
iex> Date.new(2001, 2, 29)
{:error, :invalid_date}