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.
Builds and validates an ISO date
Returns if the given year is a leap year
Converts the given structure into a string
Builds and validates an ISO date.
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.
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.
© 2012–2017 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/elixir/1.3.3/Calendar.ISO.html