From 68d53c01b0b8e9a007a6a30158c19e34b2d2a34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 18 May 2016 15:53:35 +0200 Subject: Update STDLIB documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Language cleaned up by the technical writers xsipewe and tmanevik from Combitech. Proofreading and corrections by Björn Gustavsson and Hans Bolinder. --- lib/stdlib/doc/src/calendar.xml | 248 +++++++++++++++++++++++----------------- 1 file changed, 144 insertions(+), 104 deletions(-) (limited to 'lib/stdlib/doc/src/calendar.xml') diff --git a/lib/stdlib/doc/src/calendar.xml b/lib/stdlib/doc/src/calendar.xml index 38bf55679e..65b3edcdf6 100644 --- a/lib/stdlib/doc/src/calendar.xml +++ b/lib/stdlib/doc/src/calendar.xml @@ -29,20 +29,21 @@ B calendar - Local and universal time, day-of-the-week, date and time conversions + Local and universal time, day of the week, date and time + conversions.

This module provides computation of local and universal time, - day-of-the-week, and several time conversion functions.

+ day of the week, and many 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 local_time/0 and - universal_time/0 provided in this module both return date - and time. The reason for this is that separate functions for date - and time may result in a date/time combination which is displaced - by 24 hours. This happens if one of the functions is called + universal_time/0 in this module both return date + and time. The is because separate functions for date + and time can result in a date/time combination that is displaced + by 24 hours. This occurs if one of the functions is called before midnight, and the other after midnight. This problem also applies to the Erlang BIFs date/0 and time/0, and their use is strongly discouraged if a reliable date/time stamp @@ -56,22 +57,21 @@

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 + the gregorian seconds for a specified date and time is + 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 time_difference/2 is discouraged.

-

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 iso_week_number/0 - and iso_week_number/1 returns a tuple of the year and the - week number.

+ specified as local time, they must be converted to universal time + to get the correct value of the elapsed time between epochs. + Use of function time_difference/2 is discouraged.

+

Different definitions exist for the week of the year. + This module contains a week of the year implementation + conforming to the ISO 8601 standard. As the week number for a + specified date can fall on the previous, the current, or on the next + year, it is important to specify both the year and the week number. + Functions iso_week_number/0 and iso_week_number/1 + return a tuple of the year and the week number.

@@ -86,9 +86,9 @@ -

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.

+

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.

@@ -130,186 +130,221 @@ - Compute the number of days from year 0 up to the given date + Compute the number of days from year 0 up to the specified + date. -

This function computes the number of gregorian days starting - with year 0 and ending at the given date.

+

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

+ - Compute the number of seconds from year 0 up to the given date and time + Compute the number of seconds from year 0 up to the specified + date and time. -

This function computes the number of gregorian seconds - starting with year 0 and ending at the given date and time.

+

Computes the number of gregorian seconds starting + with year 0 and ending at the specified date and time.

+ - Compute the day of the week + Compute the day of the week. -

This function computes the day of the week given Year, - Month and Day. The return value denotes the day - of the week as 1: Monday, 2: Tuesday, and so on.

+

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.

+ - Compute the date given the number of gregorian days + Compute the date from the number of gregorian days. -

This function computes the date given the number of - gregorian days.

+

Computes the date from the specified number of gregorian days.

+ - Compute the date given the number of gregorian days + Compute the date and time from the number of gregorian seconds. + -

This function computes the date and time from the given +

Computes the date and time from the specified number of gregorian seconds.

+ - Check if a year is a leap year + Check if the year is a leap year. -

This function checks if a year is a leap year.

+

Checks if the specified year is a leap year.

+ - Compute the iso week number for the actual date + Compute the ISO week number for the actual date. -

This function returns the tuple {Year, WeekNum} representing - the iso week number for the actual date. For determining the - actual date, the function local_time/0 is used.

+

Returns tuple {Year, WeekNum} representing + the ISO week number for the actual date. To determine the + actual date, use function + local_time/0.

+ - Compute the iso week number for the given date + Compute the ISO week number for the specified date. -

This function returns the tuple {Year, WeekNum} representing - the iso week number for the given date.

+

Returns tuple {Year, WeekNum} representing + the ISO week number for the specified date.

+ - Compute the number of days in a month + Compute the number of days in a month. -

This function computes the number of days in a month.

+

Computes the number of days in a month.

+ - Compute local time + Compute local time. -

This function returns the local time reported by +

Returns the local time reported by the underlying operating system.

+ - Convert from local time to universal time (deprecated) + Convert from local time to universal time (deprecated). + -

This function converts from local time to Universal - Coordinated Time (UTC). DateTime1 must refer to a local +

Converts from local time to Universal Coordinated Time (UTC). + DateTime1 must refer to a local date after Jan 1, 1970.

This function is deprecated. Use - local_time_to_universal_time_dst/1 instead, as it - gives a more correct and complete result. Especially for - the period that does not exist since it gets skipped during + + local_time_to_universal_time_dst/1 + instead, as it gives a more correct and complete result. + Especially for + the period that does not exist, as it is skipped during the switch to daylight saving time, this function still returns a result.

+ - Convert from local time to universal time(s) + Convert from local time to universal time(s). -

This function converts from local time to Universal - Coordinated Time (UTC). DateTime1 must refer to a local +

Converts from local time to Universal Coordinated Time (UTC). + DateTime1 must refer to a local date after Jan 1, 1970.

-

The return value is a list of 0, 1 or 2 possible UTC times:

+

The return value is a list of 0, 1, or 2 possible UTC times:

[]

For a local {Date1, Time1} during the period that is skipped when switching to daylight saving - time, there is no corresponding UTC since the local time - is illegal - it has never happened.

+ time, there is no corresponding UTC, as the local time + is illegal (it has never occured).

[DstDateTimeUTC, DateTimeUTC]

For a local {Date1, Time1} during the period that is repeated when switching from daylight saving - time, there are two corresponding UTCs. One for the first + time, two corresponding UTCs exist; one for the first instance of the period when daylight saving time is still active, and one for the second instance.

[DateTimeUTC] -

For all other local times there is only one - corresponding UTC.

+

For all other local times only one corresponding UTC exists.

+ + + + Convert now to date and time. + +

Returns Universal Coordinated Time (UTC) + converted from the return value from + erlang:timestamp/0. +

+
+
+ - Convert now to local date and time + Convert now to local date and time. -

This function returns local date and time converted from - the return value from - erlang:timestamp/0.

+

Returns local date and time converted from the return value from + erlang:timestamp/0. +

+ - - Convert now to date and time + Convert now to date and time. -

This function returns Universal Coordinated Time (UTC) - converted from the return value from - erlang:timestamp/0.

+

Returns Universal Coordinated Time (UTC) + converted from the return value from + erlang:timestamp/0. +

+ - Compute days and time from seconds + Compute days and time from seconds. -

This function transforms a given number of seconds into days, - hours, minutes, and seconds. The Time part is always - non-negative, but Days is negative if the argument +

Converts a specified number of seconds into days, hours, minutes, + and seconds. Time is always non-negative, but + Days is negative if argument Seconds is.

+ - Compute time from seconds + Compute time from seconds. -

This function computes the time from the given number of - seconds. Seconds must be less than the number of +

Computes the time from the specified number of seconds. + Seconds must be less than the number of seconds per day (86400).

+ - Compute the difference between two times (deprecated) + Compute the difference between two times (deprecated). + -

This function returns the difference between two {Date, Time} tuples. T2 should refer to an epoch later +

Returns the difference between two {Date, Time} tuples. + T2 is to refer to an epoch later than T1.

This function is obsolete. Use the conversion functions for @@ -317,33 +352,38 @@ + - Compute the number of seconds since midnight up to the given time + Compute the number of seconds since midnight up to the + specified time. -

This function computes the number of seconds since midnight +

Returns the number of seconds since midnight up to the specified time.

+ - Compute universal time + Compute universal 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.

+

Returns the Universal Coordinated Time (UTC) + reported by the underlying operating system. Returns local time if + universal time is unavailable.

+ - Convert from universal time to local time + Convert from universal time to local time. -

This function converts from Universal Coordinated Time (UTC) - to local time. DateTime must refer to a date after Jan 1, - 1970.

+

Converts from Universal Coordinated Time (UTC) to local time. + DateTime must refer to a date after Jan 1, 1970. +

+ @@ -362,31 +402,31 @@ Leap Years

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:

+ one of the following rules is valid:

-

Y is divisible by 4, but not by 100; or

+

Y is divisible by 4, but not by 100.

Y is divisible by 400.

-

Accordingly, 1996 is a leap year, 1900 is not, but 2000 is.

+

Hence, 1996 is a leap year, 1900 is not, but 2000 is.

Date and Time Source

Local time is obtained from the Erlang BIF localtime/0. Universal time is computed from the BIF universaltime/0.

-

The following facts apply:

+

The following fapply:

- there are 86400 seconds in a day - there are 365 days in an ordinary year - there are 366 days in a leap year - there are 1461 days in a 4 year period - there are 36524 days in a 100 year period - there are 146097 days in a 400 year period - there are 719528 days between Jan 1, 0 and Jan 1, 1970. + There are 86400 seconds in a day. + There are 365 days in an ordinary year. + There are 366 days in a leap year. + There are 1461 days in a 4 year period. + There are 36524 days in a 100 year period. + There are 146097 days in a 400 year period. + There are 719528 days between Jan 1, 0 and Jan 1, 1970.
-- cgit v1.2.3