This module provides computation of local and universal time, day-of-the-week, and several time conversion functions.
Time is local when it is adjusted in accordance with the current time zone and daylight saving. Time is universal when it reflects the time at longitude zero, without any adjustment for daylight saving. Universal Coordinated Time (UTC) time is also called Greenwich Mean Time (GMT).
The time 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 days is the number of days up to and including the date specified. Similarly, the gregorian seconds for a given date and time, is the the number of seconds up to and including the specified date and time.
For computing differences between epochs in time, use
the functions counting gregorian days or seconds. If epochs are
given as local time, they must be converted to universal time, in
order to get the correct value of the elapsed time between epochs.
Use of the function
There exists different definitions for the week of the year.
The calendar module contains a week of the year implementation
which conforms to the ISO 8601 standard. Since the week number for
a given date can fall on the previous, the current or on the next
year it is important to provide the information which year is it
together with the week number. The function
Year cannot be abbreviated. Example: 93 denotes year 93, not 1993. Valid range depends on the underlying OS. The date tuple must denote a valid date.
This function computes the number of gregorian days starting with year 0 and ending at the given date.
This function computes the number of gregorian seconds starting with year 0 and ending at the given date and time.
This function computes the day of the week given
This function computes the date given the number of gregorian days.
This function computes the date and time from the given number of gregorian seconds.
This function checks if a year is a leap year.
This function returns the tuple {Year, WeekNum} representing
the iso week number for the actual date. For determining the
actual date, the function
This function returns the tuple {Year, WeekNum} representing the iso week number for the given date.
This function computes the number of days in a month.
This function returns the local time reported by the underlying operating system.
This function converts from local time to Universal
Coordinated Time (UTC).
This function is deprecated. Use
This function converts from local time to Universal
Coordinated Time (UTC).
The return value is a list of 0, 1 or 2 possible UTC times:
For a local
For a local
For all other local times there is only one corresponding UTC.
This function returns local date and time converted from
the return value from
This function returns Universal Coordinated Time (UTC)
converted from the return value from
This function transforms a given number of seconds into days,
hours, minutes, and seconds. The
This function computes the time from the given number of
seconds.
This function returns the difference between two
This function is obsolete. Use the conversion functions for gregorian days and seconds instead.
This function computes the number of seconds since midnight up to the specified time.
This function returns the Universal Coordinated Time (UTC) reported by the underlying operating system. Local time is returned if universal time is not available.
This function converts from Universal Coordinated Time (UTC)
to local time.
This function checks if a date is a valid.
The notion that every fourth year is a leap year is not completely true. By the Gregorian rule, a year Y is a leap year if either of the following rules is valid:
Y is divisible by 4, but not by 100; or
Y is divisible by 400.
Accordingly, 1996 is a leap year, 1900 is not, but 2000 is.
Local time is obtained from the Erlang BIF
The following facts apply: