W3cubDocs

/Elixir 1.3

Calendar.ISO

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.

Summary

Functions

date(year, month, day)

Builds and validates an ISO date

leap_year?(year)

Returns if the given year is a leap year

to_string(arg1)

Converts the given structure into a string

Functions

date(year, month, day)

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}

leap_year?(year)

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

to_string(arg1)

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