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.
This commit is contained in:
Paul Eggert 2021-12-05 22:43:55 -08:00
parent 186637314d
commit 15f20c0bd0
3 changed files with 11 additions and 27 deletions

View file

@ -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))
)

View file

@ -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.

View file

@ -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