From dbef2145c78a8b6cd913d677e50a0b7df0b1b831 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 5 Dec 2021 22:52:26 -0800 Subject: [PATCH] Simplify by using format-time-string * lisp/mail/sendmail.el (mail-do-fcc): * lisp/net/tramp.el (tramp-debug-message): Prefer format-time-string to doing time formatting by hand. --- lisp/mail/sendmail.el | 14 +++++--------- lisp/net/tramp.el | 4 +--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index d0aff093dfe..d1e8a2f3c69 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -1391,8 +1391,7 @@ just append to the file, in Babyl format if necessary." (unless (markerp header-end) (error "Value of `header-end' must be a marker")) (let (fcc-list - (mailbuf (current-buffer)) - (time (current-time))) + (mailbuf (current-buffer))) (save-excursion (goto-char (point-min)) (let ((case-fold-search t)) @@ -1408,14 +1407,11 @@ just append to the file, in Babyl format if necessary." (with-temp-buffer ;; This initial newline is not written out if we create a new ;; file (see below). - (insert "\nFrom " (user-login-name) " " (current-time-string time) "\n") - ;; Insert the time zone before the year. - (forward-char -1) - (forward-word-strictly -1) (require 'mail-utils) - (insert (mail-rfc822-time-zone time) " ") - (goto-char (point-max)) - (insert "Date: " (message-make-date) "\n") + (insert "\nFrom " (user-login-name) " " + (let ((system-time-locale "C")) + (format-time-string "%a %b %e %T %z %Y")) + "\nDate: " (message-make-date) "\n") (insert-buffer-substring mailbuf) ;; Make sure messages are separated. (goto-char (point-max)) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f43c1d84b87..552788b4615 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2014,9 +2014,7 @@ ARGUMENTS to actually emit the message (if applicable)." (unless (bolp) (insert "\n")) ;; Timestamp. - (let ((now (current-time))) - (insert (format-time-string "%T." now)) - (insert (format "%06d " (nth 2 now)))) + (insert (format-time-string "%T.%6N ")) ;; Calling Tramp function. We suppress compat and trace ;; functions from being displayed. (let ((btn 1) btf fn) -- 2.39.2