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.
Converts the given date into a string
Convers the datetime (with time zone) into a string
Calculates the day of the week from the given year
, month
, and day
Returns how many days there are in the given year-month
Returns if the given year is a leap year
Converts the datetime (without time zone) into a string
day() :: 1..31
month() :: 1..12
year() :: 0..9999
Converts the given date into a string.
Convers the datetime (with time zone) into a string.
day_of_week(year, month, day) :: 1..7
Calculates the day of the week from the given year
, month
, and day
.
It is an integer from 1 to 7, where 1 is Monday and 7 is Sunday.
iex> Calendar.ISO.day_of_week(2016, 10, 31)
1
iex> Calendar.ISO.day_of_week(2016, 11, 01)
2
iex> Calendar.ISO.day_of_week(2016, 11, 02)
3
iex> Calendar.ISO.day_of_week(2016, 11, 03)
4
iex> Calendar.ISO.day_of_week(2016, 11, 04)
5
iex> Calendar.ISO.day_of_week(2016, 11, 05)
6
iex> Calendar.ISO.day_of_week(2016, 11, 06)
7
days_in_month(year, month) :: 28..31
Returns how many days there are in the given year-month.
iex> Calendar.ISO.days_in_month(1900, 1)
31
iex> Calendar.ISO.days_in_month(1900, 2)
28
iex> Calendar.ISO.days_in_month(2000, 2)
29
iex> Calendar.ISO.days_in_month(2001, 2)
28
iex> Calendar.ISO.days_in_month(2004, 2)
29
iex> Calendar.ISO.days_in_month(2004, 4)
30
leap_year?(year) :: boolean
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 datetime (without time zone) into a string.
© 2012–2017 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/elixir/1.4.1/Calendar.ISO.html