summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-12-05 22:43:55 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-12-05 23:24:09 -0800
commit15f20c0bd06a25bbb4ea90e501ef85290509c43b (patch)
treee1adafdd3420ecd38459628115baf1f05affb906
parent186637314dfa287b4b8178b668de92ecb57fdf1a (diff)
downloademacs-15f20c0bd06a25bbb4ea90e501ef85290509c43b.tar.gz
Simplify RFC 5322 time zone generation
* lisp/mail/feedmail.el (feedmail-rfc822-time-zone) (feedmail-rfc822-date, feedmail-default-message-id-generator): * lisp/mail/mail-utils.el (mail-rfc822-time-zone, mail-rfc822-date): * lisp/timezone.el (timezone-make-arpa-date): Simplify by using format-time-string with %z. * lisp/mail/feedmail.el (feedmail-rfc822-time-zone): * lisp/mail/mail-utils.el (mail-rfc822-time-zone): Mark these should-have-been-internal functions obsolete.
-rw-r--r--lisp/mail/feedmail.el18
-rw-r--r--lisp/mail/mail-utils.el15
-rw-r--r--lisp/timezone.el5
3 files changed, 11 insertions, 27 deletions
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index fe686cb6f86..32edc292619 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -2336,19 +2336,14 @@ mapped to mostly alphanumerics for safety."
;; from a similar function in mail-utils.el
(defun feedmail-rfc822-time-zone (time)
+ (declare (obsolete format-time-string "29.1"))
(feedmail-say-debug ">in-> feedmail-rfc822-time-zone %s" time)
- (let* ((sec (or (car (current-time-zone time)) 0))
- (absmin (/ (abs sec) 60)))
- (format "%c%02d%02d" (if (< sec 0) ?- ?+) (/ absmin 60) (% absmin 60))))
+ (format-time-string "%z" time))
(defun feedmail-rfc822-date (arg-time)
(feedmail-say-debug ">in-> feedmail-rfc822-date %s" arg-time)
- (let ((time (or arg-time (current-time)))
- (system-time-locale "C"))
- (concat
- (format-time-string "%a, %e %b %Y %T " time)
- (feedmail-rfc822-time-zone time)
- )))
+ (let ((system-time-locale "C"))
+ (format-time-string "%a, %e %b %Y %T %z" arg-time)))
(defun feedmail-send-it-immediately-wrapper ()
"Wrapper to catch skip-me-i."
@@ -2847,10 +2842,9 @@ probably not appropriate for you."
(if (and (not feedmail-queue-use-send-time-for-message-id) maybe-file)
(setq date-time (file-attribute-modification-time
(file-attributes maybe-file))))
- (format "<%d-%s%s%s>"
+ (format "<%d-%s%s>"
(mod (random) 10000)
- (format-time-string "%a%d%b%Y%H%M%S" date-time)
- (feedmail-rfc822-time-zone date-time)
+ (format-time-string "%a%d%b%Y%H%M%S%z" date-time)
end-stuff))
)
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index 3eb3ccb93de..f1b0590bec7 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -368,19 +368,12 @@ matches may be returned from the message body."
labels)
(defun mail-rfc822-time-zone (time)
- (let* ((sec (or (car (current-time-zone time)) 0))
- (absmin (/ (abs sec) 60)))
- (format "%c%02d%02d" (if (< sec 0) ?- ?+) (/ absmin 60) (% absmin 60))))
+ (declare (obsolete format-time-string "29.1"))
+ (format-time-string "%z" time))
(defun mail-rfc822-date ()
- (let* ((time (current-time))
- (s (current-time-string time)))
- (string-match "[^ ]+ +\\([^ ]+\\) +\\([^ ]+\\) \\([^ ]+\\) \\([^ ]+\\)" s)
- (concat (substring s (match-beginning 2) (match-end 2)) " "
- (substring s (match-beginning 1) (match-end 1)) " "
- (substring s (match-beginning 4) (match-end 4)) " "
- (substring s (match-beginning 3) (match-end 3)) " "
- (mail-rfc822-time-zone time))))
+ (let ((system-time-locale "C"))
+ (format-time-string "%-d %b %Y %T %z")))
(defun mail-mbox-from ()
"Return an mbox \"From \" line for the current message.
diff --git a/lisp/timezone.el b/lisp/timezone.el
index 2c96343a74b..0fcdbdbc16c 100644
--- a/lisp/timezone.el
+++ b/lisp/timezone.el
@@ -95,10 +95,7 @@ if nil, the local time zone is assumed."
Optional argument TIMEZONE specifies a time zone."
(let ((zone
(if (listp timezone)
- (let* ((m (timezone-zone-to-minute timezone))
- (absm (if (< m 0) (- m) m)))
- (format "%c%02d%02d"
- (if (< m 0) ?- ?+) (/ absm 60) (% absm 60)))
+ (format-time-string "%z" 0 (or timezone 0))
timezone)))
(format "%02d %s %04d %s %s"
day