W3cubDocs

/Elixir 1.4

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

Types

day()
month()
year()

Functions

date_to_string(year, month, day)

Converts the given date into a string

datetime_to_string(year, month, day, hour, minute, second, microsecond, time_zone, zone_abbr, utc_offset, std_offset)

Convers the datetime (with time zone) into a string

day_of_week(year, month, day)

Calculates the day of the week from the given year, month, and day

days_in_month(year, month)

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

leap_year?(year)

Returns if the given year is a leap year

naive_datetime_to_string(year, month, day, hour, minute, second, microsecond)

Converts the datetime (without time zone) into a string

Types

day()

day() :: 1..31

month()

month() :: 1..12

year()

year() :: 0..9999

Functions

date_to_string(year, month, day)

Converts the given date into a string.

datetime_to_string(year, month, day, hour, minute, second, microsecond, time_zone, zone_abbr, utc_offset, std_offset)

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

day_of_week(year, month, day)

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

days_in_month(year, month)

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

leap_year?(year)

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

naive_datetime_to_string(year, month, day, hour, minute, second, microsecond)

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