Elixir v1.3.4 Calendar.ISO View Source
A calendar implementation that follows to ISO8601.
This calendar implements the proleptic Gregorian calendar and is therefore compatible with the calendar used in most countries today. The proleptic means the Gregorian rules for leap years are applied for all time, consequently the dates give different results before the year 1583 from when the Gregorian calendar was adopted.
Link to this section Summary
Functions
Builds and validates an ISO date
Returns if the given year is a leap year
Converts the given structure into a string
Link to this section Functions
Builds and validates an ISO date.
Examples
iex> Calendar.ISO.date(2000, 1, 1)
{:ok, ~D[2000-01-01]}
iex> Calendar.ISO.date(2000, 13, 1)
{:error, :invalid_date}
iex> Calendar.ISO.date(2000, 2, 29)
{:ok, ~D[2000-02-29]}
iex> Calendar.ISO.date(2000, 2, 30)
{:error, :invalid_date}
iex> Calendar.ISO.date(2001, 2, 29)
{:error, :invalid_date}
Returns if the given year is a leap year.
Examples
iex> Calendar.ISO.leap_year?(2000)
true
iex> Calendar.ISO.leap_year?(2001)
false
iex> Calendar.ISO.leap_year?(2004)
true
iex> Calendar.ISO.leap_year?(1900)
false
Converts the given structure into a string.
It uses the ISO8601 standard except for DateTime where the timezone information is added between brackets.