Module calendar

A partial implementation of the Erlang/OTP calendar functions.

Description

This module provides an implementation of a subset of the functionality of the Erlang/OTP calendar functions.

All dates conform to the Gregorian calendar. This calendar was introduced by Pope Gregory XIII in 1582 and was used in all Catholic countries from this year. Protestant parts of Germany and the Netherlands adopted it in 1698, England followed in 1752, and Russia in 1918 (the October revolution of 1917 took place in November according to the Gregorian calendar).

The Gregorian calendar in this module is extended back to year 0. For a given date, the gregorian day is the number of days up to and including the date specified.

Data Types

date()


date() = {year(), month(), day()}

datetime()


datetime() = {date(), time()}

day()


day() = 1..31

day_of_week()


day_of_week() = 1..7

gregorian_days()


gregorian_days() = integer()

hour()


hour() = 0..23

minute()


minute() = 0..59

month()


month() = 1..12

second()


second() = 0..59

time()


time() = {hour(), minute(), second()}

year()


year() = integer()

Function Index

date_to_gregorian_days/1Year cannot be abbreviated.
date_to_gregorian_days/3 Computes the number of gregorian days starting with year 0 and ending at the specified date.
datetime_to_gregorian_seconds/1 Computes the number of gregorian days starting with year 0 and ending at the specified date.
day_of_the_week/1 Computes the day of the week from the specified date tuple {Year, Month, Day}.
day_of_the_week/3 Computes the day of the week from the specified Year, Month, and Day.
system_time_to_universal_time/2 Convert an integer time value to a date and time in UTC.

Function Details

date_to_gregorian_days/1


date_to_gregorian_days(Date::date()) -> Days::gregorian_days()

Date: the date to get the gregorian day count of

returns: Days number of days

Equivalent to date_to_gregorian_days(Year, M, D).

Year cannot be abbreviated.

For example, 93 denotes year 93, not 1993. The valid range depends on the underlying operating system. The date tuple must denote a valid date.

date_to_gregorian_days/3


date_to_gregorian_days(Year::year(), M::month(), D::day()) -> gregorian_days()

Year: ending year
M: ending month
D: ending day

returns: Days number of days

Computes the number of gregorian days starting with year 0 and ending at the specified date.

datetime_to_gregorian_seconds/1


datetime_to_gregorian_seconds(DateTime::datetime()) -> integer()

returns: Days number of days

Computes the number of gregorian days starting with year 0 and ending at the specified date.

day_of_the_week/1


day_of_the_week(Date::date()) -> day_of_week()

Date: the date for which to retreive the weekday

returns: Weekday day of the week

Equivalent to day_of_the_week(Y, M, D).

Computes the day of the week from the specified date tuple {Year, Month, Day}. Returns the day of the week as 1: Monday, 2: Tuesday, and so on.

day_of_the_week/3


day_of_the_week(Y::year(), M::month(), D::day()) -> day_of_week()

Y: year of the desired day
M: month of the desired day
D: year of the desired day

returns: Weekday day of the week

Computes the day of the week from the specified Year, Month, and Day. Returns the day of the week as 1: Monday, 2: Tuesday, and so on.

system_time_to_universal_time/2


system_time_to_universal_time(Time::integer(), TimeUnit::erlang:time_unit()) -> datetime()

Time: the time, as an integer, in the specified unit
TimeUnit: the time unit

Convert an integer time value to a date and time in UTC.