summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-art.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-art.el
parent0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 (diff)
downloademacs-eba66c1eafeef6512259c9b46face2b03c7433b8.tar.gz
emacs-eba66c1eafeef6512259c9b46face2b03c7433b8.tar.bz2
emacs-eba66c1eafeef6512259c9b46face2b03c7433b8.zip
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-art.el')
-rw-r--r--lisp/gnus/gnus-art.el33
1 files changed, 8 insertions, 25 deletions
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 191f623afa3..0ea156118c6 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -3540,18 +3540,11 @@ possible values."
(concat "Date: " (message-make-date time)))
;; Convert to Universal Time.
((eq type 'ut)
- (concat "Date: "
- (substring
- (message-make-date
- (let* ((e (parse-time-string date))
- (tm (encode-time e))
- (ms (car tm))
- (ls (- (cadr tm) (car (current-time-zone time)))))
- (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
- ((> ls 65535) (list (1+ ms) (- ls 65536)))
- (t (list ms ls)))))
- 0 -5)
- "UT"))
+ (let ((system-time-locale "C"))
+ (format-time-string
+ "Date: %a, %d %b %Y %T UT"
+ (encode-time (parse-time-string date))
+ t)))
;; Get the original date from the article.
((eq type 'original)
(concat "Date: " (if (string-match "\n+$" date)
@@ -3569,13 +3562,7 @@ possible values."
(concat "Date: " (format-time-string format time)))))
;; ISO 8601.
((eq type 'iso8601)
- (let ((tz (car (current-time-zone time))))
- (concat
- "Date: "
- (format-time-string "%Y%m%dT%H%M%S" time)
- (format "%s%02d%02d"
- (if (> tz 0) "+" "-") (/ (abs tz) 3600)
- (/ (% (abs tz) 3600) 60)))))
+ (format-time-string "Date: %Y%m%dT%H%M%S%z" time))
;; Do a lapsed format.
((eq type 'lapsed)
(concat "Date: " (article-lapsed-string time)))
@@ -3624,17 +3611,13 @@ possible values."
;; If the date is seriously mangled, the timezone functions are
;; liable to bug out, so we ignore all errors.
(let* ((real-time (time-subtract nil time))
- (real-sec (and real-time
- (+ (* (float (car real-time)) 65536)
- (cadr real-time))))
- (sec (and real-time (abs real-sec)))
+ (real-sec (float-time real-time))
+ (sec (abs real-sec))
(segments 0)
num prev)
(unless max-segments
(setq max-segments (length article-time-units)))
(cond
- ((null real-time)
- "Unknown")
((zerop sec)
"Now")
(t