Elixir v1.4.5 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

Converts the given date 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

Link to this section Types

Link to this type month() View Source
month() :: 1..12
Link to this type year() View Source
year() :: 0..9999

Link to this section Functions

Link to this function date_to_string(year, month, day) View Source

Converts the given date into a string.

Link to this function datetime_to_string(year, month, day, hour, minute, second, microsecond, time_zone, zone_abbr, utc_offset, std_offset) View Source

Convers the datetime (with time zone) into a string.

Link to this function day_of_week(year, month, day) View Source
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.

Examples

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
Link to this function days_in_month(year, month) View Source
days_in_month(year, month) :: 28..31

Returns how many days there are in the given year-month.

Examples

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
Link to this function leap_year?(year) View Source
leap_year?(year) :: boolean

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
Link to this function naive_datetime_to_string(year, month, day, hour, minute, second, microsecond) View Source

Converts the datetime (without time zone) into a string.