summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-diary.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-02-22 13:24:16 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-02-22 13:31:01 -0800
commiteba66c1eafeef6512259c9b46face2b03c7433b8 (patch)
tree0945a1e684448ba37146dbd36cd71dc91d70dad2 /lisp/gnus/gnus-diary.el
parent0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 (diff)
downloademacs-eba66c1eafeef6512259c9b46face2b03c7433b8.tar.gz
Remove some timestamp format assumptions
Don’t assume that current-time and plain encode-time return timestamps in (HI LO US PS) format. * lisp/gnus/gnus-art.el (article-make-date-line) (article-lapsed-string): * lisp/gnus/gnus-demon.el (gnus-demon-time-to-step): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): * lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles): * lisp/net/pop3.el (pop3-uidl-dele): * lisp/org/ox-publish.el (org-publish-sitemap): * lisp/vc/vc-hg.el (vc-hg-state-fast): Simplify and remove assumptions about timestamp format. * lisp/gnus/gnus-art.el (article-lapsed-string): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): Do not worry about time-subtract returning nil; that's not possible. * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): Avoid race due to duplicate current-time calls. * lisp/vc/vc-hg.el (vc-hg--time-to-integer): Remove; no longer used.
Diffstat (limited to 'lisp/gnus/gnus-diary.el')
-rw-r--r--lisp/gnus/gnus-diary.el45
1 files changed, 21 insertions, 24 deletions
diff --git a/lisp/gnus/gnus-diary.el b/lisp/gnus/gnus-diary.el
index 51e39958798..ceb0d4a30da 100644
--- a/lisp/gnus/gnus-diary.el
+++ b/lisp/gnus/gnus-diary.el
@@ -159,32 +159,29 @@ There are currently two built-in format functions:
;; Code partly stolen from article-make-date-line
(let* ((extras (mail-header-extra header))
(sched (gnus-diary-header-schedule extras))
- (occur (nndiary-next-occurrence sched (current-time)))
(now (current-time))
+ (occur (nndiary-next-occurrence sched now))
(real-time (time-subtract occur now)))
- (if (null real-time)
- "?????"
- (let* ((sec (+ (* (float (car real-time)) 65536) (cadr real-time)))
- (past (< sec 0))
- delay)
- (and past (setq sec (- sec)))
- (unless (zerop sec)
- ;; This is a bit convoluted, but basically we go through the time
- ;; units for years, weeks, etc, and divide things to see whether
- ;; that results in positive answers.
- (let ((units `((year . ,(* 365.25 24 3600))
- (month . ,(* 31 24 3600))
- (week . ,(* 7 24 3600))
- (day . ,(* 24 3600))
- (hour . 3600)
- (minute . 60)))
- unit num)
- (while (setq unit (pop units))
- (unless (zerop (setq num (ffloor (/ sec (cdr unit)))))
- (setq delay (append delay `((,(floor num) . ,(car unit))))))
- (setq sec (- sec (* num (cdr unit)))))))
- (funcall gnus-diary-delay-format-function past delay)))
- ))
+ (let* ((sec (encode-time real-time 'integer))
+ (past (< sec 0))
+ delay)
+ (and past (setq sec (- sec)))
+ (unless (zerop sec)
+ ;; This is a bit convoluted, but basically we go through the time
+ ;; units for years, weeks, etc, and divide things to see whether
+ ;; that results in positive answers.
+ (let ((units `((year . ,(round (* 365.25 24 3600)))
+ (month . ,(* 31 24 3600))
+ (week . ,(* 7 24 3600))
+ (day . ,(* 24 3600))
+ (hour . 3600)
+ (minute . 60)))
+ unit num)
+ (while (setq unit (pop units))
+ (unless (zerop (setq num (floor sec (cdr unit))))
+ (setq delay (append delay `((,num . ,(car unit))))))
+ (setq sec (mod sec (cdr unit))))))
+ (funcall gnus-diary-delay-format-function past delay))))
;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any
;; message, with all fields set to nil here. I don't know what it is for, and