diff options
| author | Eli Zaretskii | 2024-08-14 11:35:48 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-08-14 11:35:48 +0300 |
| commit | 9bedb957bebdca99b1bb96f58ea790e20ed48dee (patch) | |
| tree | 3dd7dbd21b40a87cf2550afa5450026c1ab6b94e /doc | |
| parent | 7c588a00655f70d4a6405642a384f34a6478628d (diff) | |
| download | emacs-9bedb957bebdca99b1bb96f58ea790e20ed48dee.tar.gz emacs-9bedb957bebdca99b1bb96f58ea790e20ed48dee.zip | |
Improve documentation of time-parsing functions
* doc/lispref/os.texi (Time Parsing):
* lisp/calendar/iso8601.el (iso8601-parse):
* lisp/calendar/parse-time.el (parse-time-string): Document that
these functions don't care about the distinction between local
time and UTC. (Bug#72570)
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/os.texi | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 3ba3da459bf..3ab4b66ba30 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1800,19 +1800,51 @@ structure (@pxref{Time Conversion}). The argument @var{string} should | |||
| 1800 | resemble an RFC 822 (or later) or ISO 8601 string, like ``Fri, 25 Mar | 1800 | resemble an RFC 822 (or later) or ISO 8601 string, like ``Fri, 25 Mar |
| 1801 | 2016 16:24:56 +0100'' or ``1998-09-12T12:21:54-0200'', but this | 1801 | 2016 16:24:56 +0100'' or ``1998-09-12T12:21:54-0200'', but this |
| 1802 | function will attempt to parse less well-formed time strings as well. | 1802 | function will attempt to parse less well-formed time strings as well. |
| 1803 | |||
| 1804 | Note that, unlike @code{decode-time} (@pxref{Time Conversion}), this | ||
| 1805 | function does not interpret the time string, and in particular the | ||
| 1806 | values of daylight-saving and timezone or UTC offset parts of the | ||
| 1807 | @var{string} argument do not affect the returned value of date and time, | ||
| 1808 | they only affect the last two members of the returned decoded time | ||
| 1809 | structure. For example, if the time-zone information is present in | ||
| 1810 | @var{string}, the decoded time structure will include it; otherwise the | ||
| 1811 | time-zone member of the returned value will be @code{nil}. In other | ||
| 1812 | words, this function simply parses the textual representation of date | ||
| 1813 | and time into separate numerical values, and doesn't care whether the | ||
| 1814 | input time is local or UTC. | ||
| 1815 | |||
| 1816 | If a Lisp program passes the return value of this function to some other | ||
| 1817 | time-related API, it should make sure the @code{nil} members of the | ||
| 1818 | decoded time structure are interpreted correctly, and in particular the | ||
| 1819 | lack of time-zone information is interpreted as UTC or local time, | ||
| 1820 | according to the needs of the calling program. | ||
| 1803 | @end defun | 1821 | @end defun |
| 1804 | 1822 | ||
| 1805 | @vindex ISO 8601 date/time strings | 1823 | @vindex ISO 8601 date/time strings |
| 1806 | @defun iso8601-parse string | 1824 | @defun iso8601-parse string |
| 1807 | For a more strict function (that will error out upon invalid input), | 1825 | For a more strict function (that will error out upon invalid input), |
| 1808 | this function can be used instead. It can parse all variants of | 1826 | Lisp programs can use this function instead. It can parse all variants |
| 1809 | the ISO 8601 standard, so in addition to the formats mentioned above, | 1827 | of the ISO 8601 standard, so in addition to the formats mentioned above, |
| 1810 | it also parses things like ``1998W45-3'' (week number) and | 1828 | it also parses things like ``1998W45-3'' (week number) and ``1998-245'' |
| 1811 | ``1998-245'' (ordinal day number). To parse durations, there's | 1829 | (ordinal day number). To parse durations, there's |
| 1812 | @code{iso8601-parse-duration}, and to parse intervals, there's | 1830 | @code{iso8601-parse-duration}, and to parse intervals, there's |
| 1813 | @code{iso8601-parse-interval}. All these functions return decoded | 1831 | @code{iso8601-parse-interval}. All these functions return decoded time |
| 1814 | time structures, except the final one, which returns three of them | 1832 | structures, except the final one, which returns three of them (the |
| 1815 | (the start, the end, and the duration). | 1833 | start, the end, and the duration). |
| 1834 | |||
| 1835 | Like @code{parse-time-string}, this function does not interpret the time | ||
| 1836 | string, and in particular the time-zone designator or UTC offset that is | ||
| 1837 | part of the @var{string} argument does not affect the returned value of | ||
| 1838 | date and time, it only affects the last two members of the returned | ||
| 1839 | decoded time structure. The ISO 8601 standard specifies that date/time | ||
| 1840 | strings that do not include information about UTC relation are assumed | ||
| 1841 | to be in local time, but this function does not do that, because it | ||
| 1842 | doesn't interpret the time values. For example, if the time-zone | ||
| 1843 | information is present in @var{string}, the decoded time structure will | ||
| 1844 | include it; otherwise the time-zone member of the returned value will be | ||
| 1845 | @code{nil}. In other words, this function simply parses the textual | ||
| 1846 | representation of date and time into separate numerical values, and | ||
| 1847 | doesn't care whether the input time is local or UTC. | ||
| 1816 | @end defun | 1848 | @end defun |
| 1817 | 1849 | ||
| 1818 | @defun format-time-string format-string &optional time zone | 1850 | @defun format-time-string format-string &optional time zone |