diff options
| author | Paul Eggert | 2019-08-04 09:57:27 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-08-04 10:09:25 -0700 |
| commit | 5f3f3884a0d2a88101d330b82ef5b584cfc02aa6 (patch) | |
| tree | 1fe0f5f8779f6836748d26ecfc58cee88da8e46e | |
| parent | f01597a43ea2eac38cfbb829f301c2e6e3bcbe83 (diff) | |
| download | emacs-5f3f3884a0d2a88101d330b82ef5b584cfc02aa6.tar.gz emacs-5f3f3884a0d2a88101d330b82ef5b584cfc02aa6.zip | |
Improve time function doc
* doc/misc/emacs-mime.texi (time-date): Don’t give
parse-iso8601-time-string in the example, as the function is
not autoloaded.
* lisp/gnus/nndiary.el (nndiary-compute-reminders):
No need to call encode-time or use floating point here.
| -rw-r--r-- | doc/lispref/os.texi | 4 | ||||
| -rw-r--r-- | doc/misc/emacs-mime.texi | 6 | ||||
| -rw-r--r-- | lisp/calendar/iso8601.el | 2 | ||||
| -rw-r--r-- | lisp/calendar/time-date.el | 4 | ||||
| -rw-r--r-- | lisp/gnus/nndiary.el | 12 | ||||
| -rw-r--r-- | lisp/net/soap-client.el | 1 | ||||
| -rw-r--r-- | lisp/org/org-id.el | 7 |
7 files changed, 18 insertions, 18 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index b3444838d3b..7bb9833467d 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1559,7 +1559,7 @@ or more arguments. The first six arguments @var{second}, | |||
| 1559 | specify most of the components of a decoded time. If there are more | 1559 | specify most of the components of a decoded time. If there are more |
| 1560 | than six arguments the @emph{last} argument is used as @var{zone} and | 1560 | than six arguments the @emph{last} argument is used as @var{zone} and |
| 1561 | any other extra arguments are ignored, so that @code{(apply | 1561 | any other extra arguments are ignored, so that @code{(apply |
| 1562 | #\\='encode-time (decode-time ...))} works; otherwise @var{zone} defaults | 1562 | #'encode-time (decode-time ...))} works; otherwise @var{zone} defaults |
| 1563 | to the current time zone rule (@pxref{Time Zone Rules}). The decoded | 1563 | to the current time zone rule (@pxref{Time Zone Rules}). The decoded |
| 1564 | time's @var{dst} component is treated as if it was @minus{}1, and | 1564 | time's @var{dst} component is treated as if it was @minus{}1, and |
| 1565 | @var{form} takes its default value. | 1565 | @var{form} takes its default value. |
| @@ -1581,7 +1581,7 @@ You can perform simple date arithmetic by using out-of-range values for | |||
| 1581 | for example, day 0 means the day preceding the given month. | 1581 | for example, day 0 means the day preceding the given month. |
| 1582 | 1582 | ||
| 1583 | The operating system puts limits on the range of possible time values; | 1583 | The operating system puts limits on the range of possible time values; |
| 1584 | if you try to encode a time that is out of range, an error results. | 1584 | if the limits are exceeded while encoding the time, an error results. |
| 1585 | For instance, years before 1970 do not work on some systems; | 1585 | For instance, years before 1970 do not work on some systems; |
| 1586 | on others, years as early as 1901 do work. | 1586 | on others, years as early as 1901 do work. |
| 1587 | @end defun | 1587 | @end defun |
diff --git a/doc/misc/emacs-mime.texi b/doc/misc/emacs-mime.texi index 6e95013c186..1f384f4f270 100644 --- a/doc/misc/emacs-mime.texi +++ b/doc/misc/emacs-mime.texi | |||
| @@ -1541,10 +1541,6 @@ Here's a bunch of time/date/second/day examples: | |||
| 1541 | 1000000) | 1541 | 1000000) |
| 1542 | @result{} (905595714000000 . 1000000) | 1542 | @result{} (905595714000000 . 1000000) |
| 1543 | 1543 | ||
| 1544 | (encode-time (parse-iso8601-time-string "1998-09-12T12:21:54+0200") | ||
| 1545 | 1000000) | ||
| 1546 | @result{} (905595714000000 . 1000000) | ||
| 1547 | |||
| 1548 | (float-time '(905595714000000 . 1000000)) | 1544 | (float-time '(905595714000000 . 1000000)) |
| 1549 | @result{} 905595714.0 | 1545 | @result{} 905595714.0 |
| 1550 | 1546 | ||
| @@ -1627,7 +1623,7 @@ These are the functions available: | |||
| 1627 | Take a date and return a time. | 1623 | Take a date and return a time. |
| 1628 | 1624 | ||
| 1629 | @item float-time | 1625 | @item float-time |
| 1630 | Take a time and return seconds. (This is a built-in function.) | 1626 | Take a time and return seconds. |
| 1631 | 1627 | ||
| 1632 | @item encode-time | 1628 | @item encode-time |
| 1633 | Take seconds (and other ways to represent time, notably decoded time | 1629 | Take seconds (and other ways to represent time, notably decoded time |
diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index c69156cbeb6..30352c7e75f 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el | |||
| @@ -138,7 +138,7 @@ well as variants like \"2008W32\" (week number) and | |||
| 138 | date))) | 138 | date))) |
| 139 | 139 | ||
| 140 | (defun iso8601-parse-date (string) | 140 | (defun iso8601-parse-date (string) |
| 141 | "Parse STRING (which should be on ISO 8601 format) and return a time value." | 141 | "Parse STRING (in ISO 8601 format) and return a decoded time value." |
| 142 | (cond | 142 | (cond |
| 143 | ;; Just a year: [-+]YYYY. | 143 | ;; Just a year: [-+]YYYY. |
| 144 | ((iso8601--match iso8601--year-match string) | 144 | ((iso8601--match iso8601--year-match string) |
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 5b82b8ab0fa..c0565b3cfb7 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -374,8 +374,8 @@ January 1st being 1." | |||
| 374 | 374 | ||
| 375 | (defun decoded-time-add (time delta) | 375 | (defun decoded-time-add (time delta) |
| 376 | "Add DELTA to TIME, both of which are `decoded-time' structures. | 376 | "Add DELTA to TIME, both of which are `decoded-time' structures. |
| 377 | TIME should represent a time, while DELTA should only have | 377 | TIME should represent a time, while DELTA should have non-nil |
| 378 | non-nil integers for the values that should be altered. | 378 | entries only for the values that should be altered. |
| 379 | 379 | ||
| 380 | For instance, if you want to \"add two months\" to TIME, then | 380 | For instance, if you want to \"add two months\" to TIME, then |
| 381 | leave all other fields but the month field in DELTA nil, and make | 381 | leave all other fields but the month field in DELTA nil, and make |
diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el index 2ad0634e6ad..8cda5aa7031 100644 --- a/lisp/gnus/nndiary.el +++ b/lisp/gnus/nndiary.el | |||
| @@ -1278,27 +1278,27 @@ all. This may very well take some time.") | |||
| 1278 | (cond ((eq (cdr reminder) 'minute) | 1278 | (cond ((eq (cdr reminder) 'minute) |
| 1279 | (time-subtract | 1279 | (time-subtract |
| 1280 | (apply #'encode-time 0 (nthcdr 1 date-elts)) | 1280 | (apply #'encode-time 0 (nthcdr 1 date-elts)) |
| 1281 | (encode-time (* (car reminder) 60.0)))) | 1281 | (* (car reminder) 60))) |
| 1282 | ((eq (cdr reminder) 'hour) | 1282 | ((eq (cdr reminder) 'hour) |
| 1283 | (time-subtract | 1283 | (time-subtract |
| 1284 | (apply #'encode-time 0 0 (nthcdr 2 date-elts)) | 1284 | (apply #'encode-time 0 0 (nthcdr 2 date-elts)) |
| 1285 | (encode-time (* (car reminder) 3600.0)))) | 1285 | (* (car reminder) 3600))) |
| 1286 | ((eq (cdr reminder) 'day) | 1286 | ((eq (cdr reminder) 'day) |
| 1287 | (time-subtract | 1287 | (time-subtract |
| 1288 | (apply #'encode-time 0 0 0 (nthcdr 3 date-elts)) | 1288 | (apply #'encode-time 0 0 0 (nthcdr 3 date-elts)) |
| 1289 | (encode-time (* (car reminder) 86400.0)))) | 1289 | (* (car reminder) 86400))) |
| 1290 | ((eq (cdr reminder) 'week) | 1290 | ((eq (cdr reminder) 'week) |
| 1291 | (time-subtract | 1291 | (time-subtract |
| 1292 | (apply #'encode-time 0 0 0 monday (nthcdr 4 date-elts)) | 1292 | (apply #'encode-time 0 0 0 monday (nthcdr 4 date-elts)) |
| 1293 | (encode-time (* (car reminder) 604800.0)))) | 1293 | (* (car reminder) 604800))) |
| 1294 | ((eq (cdr reminder) 'month) | 1294 | ((eq (cdr reminder) 'month) |
| 1295 | (time-subtract | 1295 | (time-subtract |
| 1296 | (apply #'encode-time 0 0 0 1 (nthcdr 4 date-elts)) | 1296 | (apply #'encode-time 0 0 0 1 (nthcdr 4 date-elts)) |
| 1297 | (encode-time (* (car reminder) 18748800.0)))) | 1297 | (* (car reminder) 18748800))) |
| 1298 | ((eq (cdr reminder) 'year) | 1298 | ((eq (cdr reminder) 'year) |
| 1299 | (time-subtract | 1299 | (time-subtract |
| 1300 | (apply #'encode-time 0 0 0 1 1 (nthcdr 5 date-elts)) | 1300 | (apply #'encode-time 0 0 0 1 1 (nthcdr 5 date-elts)) |
| 1301 | (encode-time (* (car reminder) 400861056.0))))) | 1301 | (* (car reminder) 400861056)))) |
| 1302 | res)) | 1302 | res)) |
| 1303 | (sort res 'time-less-p))) | 1303 | (sort res 'time-less-p))) |
| 1304 | 1304 | ||
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el index 5526d624f96..95f208baf98 100644 --- a/lisp/net/soap-client.el +++ b/lisp/net/soap-client.el | |||
| @@ -636,6 +636,7 @@ disallows them." | |||
| 636 | (error "Invalid or unsupported time: %s" date-time-string)) | 636 | (error "Invalid or unsupported time: %s" date-time-string)) |
| 637 | ;; Return a value in a format similar to that returned by decode-time, and | 637 | ;; Return a value in a format similar to that returned by decode-time, and |
| 638 | ;; suitable for (apply #'encode-time ...). | 638 | ;; suitable for (apply #'encode-time ...). |
| 639 | ;; FIXME: Nobody uses this idiosyncratic value. Perhaps stop returning it? | ||
| 639 | (list second minute hour day month year second-fraction datatype | 640 | (list second minute hour day month year second-fraction datatype |
| 640 | (if has-time-zone | 641 | (if has-time-zone |
| 641 | (* (rng-xsd-time-to-seconds | 642 | (* (rng-xsd-time-to-seconds |
diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el index 44cc7b2f14d..8f9c132ad37 100644 --- a/lisp/org/org-id.el +++ b/lisp/org/org-id.el | |||
| @@ -412,9 +412,12 @@ The input I may be a character, or a single-letter string." | |||
| 412 | r)) | 412 | r)) |
| 413 | 413 | ||
| 414 | (defun org-id-time-to-b36 (&optional time) | 414 | (defun org-id-time-to-b36 (&optional time) |
| 415 | "Encode TIME as a 10-digit string. | 415 | "Encode TIME as a 12-digit string. |
| 416 | This string holds the time to micro-second accuracy, and can be decoded | 416 | This string holds the time to micro-second accuracy, and can be decoded |
| 417 | using `org-id-decode'." | 417 | using `org-id-decode'." |
| 418 | ;; FIXME: If TIME represents N seconds after the epoch, then | ||
| 419 | ;; this encoding assumes 0 <= N < 110075314176 = (* (expt 36 4) 65536), | ||
| 420 | ;; i.e., that TIME is from 1970-01-01 00:00:00 to 5458-02-23 20:09:36 UTC. | ||
| 418 | (setq time (encode-time time 'list)) | 421 | (setq time (encode-time time 'list)) |
| 419 | (concat (org-id-int-to-b36 (nth 0 time) 4) | 422 | (concat (org-id-int-to-b36 (nth 0 time) 4) |
| 420 | (org-id-int-to-b36 (nth 1 time) 4) | 423 | (org-id-int-to-b36 (nth 1 time) 4) |
| @@ -423,7 +426,7 @@ using `org-id-decode'." | |||
| 423 | (defun org-id-decode (id) | 426 | (defun org-id-decode (id) |
| 424 | "Split ID into the prefix and the time value that was used to create it. | 427 | "Split ID into the prefix and the time value that was used to create it. |
| 425 | The return value is (prefix . time) where PREFIX is nil or a string, | 428 | The return value is (prefix . time) where PREFIX is nil or a string, |
| 426 | and time is the usual three-integer representation of time." | 429 | and TIME is a Lisp time value (HI LO USEC)." |
| 427 | (let (prefix time parts) | 430 | (let (prefix time parts) |
| 428 | (setq parts (org-split-string id ":")) | 431 | (setq parts (org-split-string id ":")) |
| 429 | (if (= 2 (length parts)) | 432 | (if (= 2 (length parts)) |