diff options
| author | Paul Eggert | 2024-08-12 14:31:19 -0700 |
|---|---|---|
| committer | Paul Eggert | 2024-08-12 14:52:34 -0700 |
| commit | 7a828c938ca9daf37baa02a50bb6463e2b7c0b85 (patch) | |
| tree | e823c7cbef9be1ac238f077c539bbb51799f2258 | |
| parent | 5d69e2916458148159d7f21257f3c4863b868690 (diff) | |
| download | emacs-7a828c938ca9daf37baa02a50bb6463e2b7c0b85.tar.gz emacs-7a828c938ca9daf37baa02a50bb6463e2b7c0b85.zip | |
Document time-parsing functions a bit better
See <https://bugs.gnu.org/72570#14>
| -rw-r--r-- | doc/lispref/os.texi | 26 | ||||
| -rw-r--r-- | lisp/calendar/iso8601.el | 10 | ||||
| -rw-r--r-- | lisp/calendar/parse-time.el | 5 |
3 files changed, 26 insertions, 15 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 3ba3da459bf..5839de4a650 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1800,19 +1800,31 @@ 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 | It parses an incomplete string like ``2024-08-13'' to an incomplete | ||
| 1804 | structure like @samp{(nil nil nil 13 8 2024 nil -1 nil)}, in which | ||
| 1805 | an unknown DST value is @minus{}1 and other unknown values are @code{nil}. | ||
| 1803 | @end defun | 1806 | @end defun |
| 1804 | 1807 | ||
| 1805 | @vindex ISO 8601 date/time strings | 1808 | @vindex ISO 8601 date/time strings |
| 1806 | @defun iso8601-parse string | 1809 | @defun iso8601-parse string |
| 1807 | For a more strict function (that will error out upon invalid input), | 1810 | This function acts like @code{parse-time-string} except it is stricter |
| 1808 | this function can be used instead. It can parse all variants of | 1811 | and errors out upon invalid input. It can parse all variants of |
| 1809 | the ISO 8601 standard, so in addition to the formats mentioned above, | 1812 | the ISO 8601 standard, so in addition to the formats mentioned above, |
| 1810 | it also parses things like ``1998W45-3'' (week number) and | 1813 | it also parses things like ``1998W45-3'' (week number) and |
| 1811 | ``1998-245'' (ordinal day number). To parse durations, there's | 1814 | ``1998-245'' (ordinal day number). |
| 1812 | @code{iso8601-parse-duration}, and to parse intervals, there's | 1815 | @end defun |
| 1813 | @code{iso8601-parse-interval}. All these functions return decoded | 1816 | |
| 1814 | time structures, except the final one, which returns three of them | 1817 | @defun iso8601-parse-duration string |
| 1815 | (the start, the end, and the duration). | 1818 | This function parses an ISO 8601 time duration @var{string} |
| 1819 | and returns a decoded time structure. | ||
| 1820 | @c FIXME: example? behavior on incomplete input? | ||
| 1821 | @end defun | ||
| 1822 | |||
| 1823 | @defun iso8601-parse-interval string | ||
| 1824 | This function parses an ISO 8601 time interval @var{string} | ||
| 1825 | and returns three decoded time structures | ||
| 1826 | representing the start, the end, and the duration. | ||
| 1827 | @c FIXME: example? behavior on incomplete input? | ||
| 1816 | @end defun | 1828 | @end defun |
| 1817 | 1829 | ||
| 1818 | @defun format-time-string format-string &optional time zone | 1830 | @defun format-time-string format-string &optional time zone |
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index a32b52564c9..a31b60eaec2 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el | |||
| @@ -121,11 +121,11 @@ | |||
| 121 | 121 | ||
| 122 | (defun iso8601-parse (string &optional form) | 122 | (defun iso8601-parse (string &optional form) |
| 123 | "Parse an ISO 8601 date/time string and return a `decode-time' structure. | 123 | "Parse an ISO 8601 date/time string and return a `decode-time' structure. |
| 124 | 124 | ISO 8601 date/time strings look like \"2008-03-02T13:47:30+05:30\", | |
| 125 | The ISO 8601 date/time strings look like \"2008-03-02T13:47:30\", | 125 | or like shorter, incomplete strings like date \"2008-03-02\", |
| 126 | but shorter, incomplete strings like \"2008-03-02\" are valid, as | 126 | week number \"2008W32\", and ordinal day number \"2008-234\". |
| 127 | well as variants like \"2008W32\" (week number) and | 127 | Values returned are identical to those of `decode-time', except |
| 128 | \"2008-234\" (ordinal day number). | 128 | that an unknown DST value is -1 and other unknown values are nil. |
| 129 | 129 | ||
| 130 | See `decode-time' for the meaning of FORM." | 130 | See `decode-time' for the meaning of FORM." |
| 131 | (if (not (iso8601-valid-p string)) | 131 | (if (not (iso8601-valid-p string)) |
diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index c34329a4002..9538ea92ee5 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el | |||
| @@ -154,9 +154,8 @@ or something resembling an RFC 822 (or later) date-time, e.g., | |||
| 154 | \"Wed, 15 Jan 2020 16:12:21 -0800\". This function is | 154 | \"Wed, 15 Jan 2020 16:12:21 -0800\". This function is |
| 155 | somewhat liberal in what format it accepts, and will attempt to | 155 | somewhat liberal in what format it accepts, and will attempt to |
| 156 | return a \"likely\" value even for somewhat malformed strings. | 156 | return a \"likely\" value even for somewhat malformed strings. |
| 157 | The values returned are identical to those of `decode-time', but | 157 | Values returned are identical to those of `decode-time', except |
| 158 | any unknown values other than DST are returned as nil, and an | 158 | that an unknown DST value is -1 and other unknown values are nil. |
| 159 | unknown DST value is returned as -1. | ||
| 160 | 159 | ||
| 161 | See `decode-time' for the meaning of FORM." | 160 | See `decode-time' for the meaning of FORM." |
| 162 | (condition-case () | 161 | (condition-case () |