diff options
| author | Paul Eggert | 2019-11-01 16:13:31 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-11-01 16:13:50 -0700 |
| commit | 9b1c00b3ca1a1f841cdcfd880536b0dc7669738a (patch) | |
| tree | fff3a2c8d45fe2f092c7cbcd41cafc294fcebac6 | |
| parent | a8b87446656af0395864b7aaa697a4e04bcc1218 (diff) | |
| download | emacs-9b1c00b3ca1a1f841cdcfd880536b0dc7669738a.tar.gz emacs-9b1c00b3ca1a1f841cdcfd880536b0dc7669738a.zip | |
Document limits on some time-conversion functions
* doc/lispref/os.texi (Time of Day, Time Zone Rules)
(Time Conversion, Time Parsing, Time Calculations):
Document functions that limit the range of time values
due to OS limits (Bug#37974).
| -rw-r--r-- | doc/lispref/os.texi | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index d8d0ad7206d..d3ddee251b7 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1307,7 +1307,14 @@ format, which can be a Lisp timestamp, @code{nil} for the current | |||
| 1307 | time, a single floating-point number for seconds, or a list | 1307 | time, a single floating-point number for seconds, or a list |
| 1308 | @code{(@var{high} @var{low} @var{micro})} or @code{(@var{high} | 1308 | @code{(@var{high} @var{low} @var{micro})} or @code{(@var{high} |
| 1309 | @var{low})} that is a truncated list timestamp with missing elements | 1309 | @var{low})} that is a truncated list timestamp with missing elements |
| 1310 | taken to be zero. You can convert a time value into | 1310 | taken to be zero. |
| 1311 | |||
| 1312 | Time values can be converted to and from calendrical and other forms. | ||
| 1313 | Some of these conversions rely on operating system functions that | ||
| 1314 | limit the range of possible time values, and signal an error if the | ||
| 1315 | limits are exceeded. For instance, a system may not support years | ||
| 1316 | before 1970, or years before 1901, or years far in the future. | ||
| 1317 | You can convert a time value into | ||
| 1311 | a human-readable string using @code{format-time-string}, into a Lisp | 1318 | a human-readable string using @code{format-time-string}, into a Lisp |
| 1312 | timestamp using @code{time-convert}, and into other forms using | 1319 | timestamp using @code{time-convert}, and into other forms using |
| 1313 | @code{decode-time} and @code{float-time}. These functions are | 1320 | @code{decode-time} and @code{float-time}. These functions are |
| @@ -1328,11 +1335,12 @@ information may some day be added at the end. | |||
| 1328 | The argument @var{time}, if given, specifies a time to format, | 1335 | The argument @var{time}, if given, specifies a time to format, |
| 1329 | instead of the current time. The optional argument @var{zone} | 1336 | instead of the current time. The optional argument @var{zone} |
| 1330 | defaults to the current time zone rule. @xref{Time Zone Rules}. | 1337 | defaults to the current time zone rule. @xref{Time Zone Rules}. |
| 1338 | The operating system limits the range of time and zone values. | ||
| 1331 | 1339 | ||
| 1332 | @example | 1340 | @example |
| 1333 | @group | 1341 | @group |
| 1334 | (current-time-string) | 1342 | (current-time-string) |
| 1335 | @result{} "Wed Oct 14 22:21:05 1987" | 1343 | @result{} "Fri Nov @ 1 15:59:49 2019" |
| 1336 | @end group | 1344 | @end group |
| 1337 | @end example | 1345 | @end example |
| 1338 | @end defun | 1346 | @end defun |
| @@ -1416,6 +1424,7 @@ compute the value, the unknown elements of the list are @code{nil}. | |||
| 1416 | The argument @var{time}, if given, specifies a time value to | 1424 | The argument @var{time}, if given, specifies a time value to |
| 1417 | analyze instead of the current time. The optional argument @var{zone} | 1425 | analyze instead of the current time. The optional argument @var{zone} |
| 1418 | defaults to the current time zone rule. | 1426 | defaults to the current time zone rule. |
| 1427 | The operating system limits the range of time and zone values. | ||
| 1419 | @end defun | 1428 | @end defun |
| 1420 | 1429 | ||
| 1421 | @node Time Conversion | 1430 | @node Time Conversion |
| @@ -1498,6 +1507,8 @@ Although @code{(time-convert nil nil)} is equivalent to | |||
| 1498 | This function converts a time value into calendrical information. If | 1507 | This function converts a time value into calendrical information. If |
| 1499 | you don't specify @var{time}, it decodes the current time, and similarly | 1508 | you don't specify @var{time}, it decodes the current time, and similarly |
| 1500 | @var{zone} defaults to the current time zone rule. @xref{Time Zone Rules}. | 1509 | @var{zone} defaults to the current time zone rule. @xref{Time Zone Rules}. |
| 1510 | The operating system limits the range of time and zone values. | ||
| 1511 | |||
| 1501 | The @var{form} argument controls the form of the returned | 1512 | The @var{form} argument controls the form of the returned |
| 1502 | @var{seconds} element, as described below. | 1513 | @var{seconds} element, as described below. |
| 1503 | The return value is a list of nine elements, as follows: | 1514 | The return value is a list of nine elements, as follows: |
| @@ -1631,6 +1642,7 @@ convention, @var{zone} defaults to the current time zone rule | |||
| 1631 | Year numbers less than 100 are not treated specially. If you want them | 1642 | Year numbers less than 100 are not treated specially. If you want them |
| 1632 | to stand for years above 1900, or years above 2000, you must alter them | 1643 | to stand for years above 1900, or years above 2000, you must alter them |
| 1633 | yourself before you call @code{encode-time}. | 1644 | yourself before you call @code{encode-time}. |
| 1645 | The operating system limits the range of time values. | ||
| 1634 | 1646 | ||
| 1635 | The @code{encode-time} function acts as a rough inverse to | 1647 | The @code{encode-time} function acts as a rough inverse to |
| 1636 | @code{decode-time}. For example, you can pass the output of | 1648 | @code{decode-time}. For example, you can pass the output of |
| @@ -1643,11 +1655,6 @@ the latter to the former as follows: | |||
| 1643 | You can perform simple date arithmetic by using out-of-range values for | 1655 | You can perform simple date arithmetic by using out-of-range values for |
| 1644 | @var{seconds}, @var{minutes}, @var{hour}, @var{day}, and @var{month}; | 1656 | @var{seconds}, @var{minutes}, @var{hour}, @var{day}, and @var{month}; |
| 1645 | for example, day 0 means the day preceding the given month. | 1657 | for example, day 0 means the day preceding the given month. |
| 1646 | |||
| 1647 | The operating system puts limits on the range of possible time values; | ||
| 1648 | if the limits are exceeded while encoding the time, an error results. | ||
| 1649 | For instance, years before 1970 do not work on some systems; | ||
| 1650 | on others, years as early as 1901 do work. | ||
| 1651 | @end defun | 1658 | @end defun |
| 1652 | 1659 | ||
| 1653 | @node Time Parsing | 1660 | @node Time Parsing |
| @@ -1666,6 +1673,7 @@ corresponding Lisp timestamp. The argument @var{string} should represent | |||
| 1666 | a date-time, and should be in one of the forms recognized by | 1673 | a date-time, and should be in one of the forms recognized by |
| 1667 | @code{parse-time-string} (see below). This function assumes the GMT | 1674 | @code{parse-time-string} (see below). This function assumes the GMT |
| 1668 | timezone if @var{string} lacks an explicit timezone information. | 1675 | timezone if @var{string} lacks an explicit timezone information. |
| 1676 | The operating system limits the range of time values. | ||
| 1669 | @end defun | 1677 | @end defun |
| 1670 | 1678 | ||
| 1671 | @defun parse-time-string string | 1679 | @defun parse-time-string string |
| @@ -1847,10 +1855,12 @@ behavior, as future versions of Emacs may recognize new | |||
| 1847 | This function uses the C library function @code{strftime} | 1855 | This function uses the C library function @code{strftime} |
| 1848 | (@pxref{Formatting Calendar Time,,, libc, The GNU C Library Reference | 1856 | (@pxref{Formatting Calendar Time,,, libc, The GNU C Library Reference |
| 1849 | Manual}) to do most of the work. In order to communicate with that | 1857 | Manual}) to do most of the work. In order to communicate with that |
| 1850 | function, it first encodes its argument using the coding system | 1858 | function, it first converts @var{time} and @var{zone} to internal form; |
| 1859 | the operating system limits the range of time and zone values. | ||
| 1860 | This function also encodes @var{format-string} using the coding system | ||
| 1851 | specified by @code{locale-coding-system} (@pxref{Locales}); after | 1861 | specified by @code{locale-coding-system} (@pxref{Locales}); after |
| 1852 | @code{strftime} returns the resulting string, | 1862 | @code{strftime} returns the resulting string, |
| 1853 | @code{format-time-string} decodes the string using that same coding | 1863 | this function decodes the string using that same coding |
| 1854 | system. | 1864 | system. |
| 1855 | @end defun | 1865 | @end defun |
| 1856 | 1866 | ||
| @@ -1990,10 +2000,12 @@ Here is how to add a number of seconds to a time value: | |||
| 1990 | @defun time-to-days time-value | 2000 | @defun time-to-days time-value |
| 1991 | This function returns the number of days between the beginning of year | 2001 | This function returns the number of days between the beginning of year |
| 1992 | 1 and @var{time-value}. | 2002 | 1 and @var{time-value}. |
| 2003 | The operating system limits the range of time values. | ||
| 1993 | @end defun | 2004 | @end defun |
| 1994 | 2005 | ||
| 1995 | @defun time-to-day-in-year time-value | 2006 | @defun time-to-day-in-year time-value |
| 1996 | This returns the day number within the year corresponding to @var{time-value}. | 2007 | This returns the day number within the year corresponding to @var{time-value}. |
| 2008 | The operating system limits the range of time values. | ||
| 1997 | @end defun | 2009 | @end defun |
| 1998 | 2010 | ||
| 1999 | @defun date-leap-year-p year | 2011 | @defun date-leap-year-p year |
| @@ -2002,7 +2014,7 @@ This function returns @code{t} if @var{year} is a leap year. | |||
| 2002 | 2014 | ||
| 2003 | @defun date-days-in-month year month | 2015 | @defun date-days-in-month year month |
| 2004 | Return the number of days in @var{month} in @var{year}. For instance, | 2016 | Return the number of days in @var{month} in @var{year}. For instance, |
| 2005 | there's 29 days in February 2004. | 2017 | February 2020 has 29 days. |
| 2006 | @end defun | 2018 | @end defun |
| 2007 | 2019 | ||
| 2008 | @defun date-ordinal-to-time year ordinal | 2020 | @defun date-ordinal-to-time year ordinal |