[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cea0d61 4/9: Prefer format-time-string to current-time-string
From: |
Paul Eggert |
Subject: |
master cea0d61 4/9: Prefer format-time-string to current-time-string |
Date: |
Thu, 16 Dec 2021 14:17:37 -0500 (EST) |
branch: master
commit cea0d61a69ef443924fdd4e4c429d7103b4acb9a
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
Prefer format-time-string to current-time-string
* lisp/arc-mode.el (archive-unixdate):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/tar-mode.el (tar-clip-time-string):
Prefer format-time-string to reassembling current-time-string output.
---
doc/lispref/os.texi | 2 +-
lisp/arc-mode.el | 8 ++------
lisp/gnus/nnrss.el | 16 ++++++++--------
lisp/tar-mode.el | 4 ++--
4 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index b4efc44..e369618 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1352,7 +1352,7 @@ may change as higher-resolution clocks become available.
@cindex time value
Function arguments, e.g., the @var{time} argument to
-@code{current-time-string}, accept a more-general @dfn{time value}
+@code{format-time-string}, accept a more-general @dfn{time value}
format, which can be a Lisp timestamp, @code{nil} for the current
time, a single floating-point number for seconds, or a list
@code{(@var{high} @var{low} @var{micro})} or @code{(@var{high}
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 1fd1d66..ece30fe 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -617,12 +617,8 @@ OLDMODE will be modified accordingly just like chmod(2)
would have done."
(defun archive-unixdate (low high)
"Stringify Unix (LOW HIGH) date."
- (let* ((time (list high low))
- (str (current-time-string time)))
- (format "%s-%s-%s"
- (substring str 8 10)
- (substring str 4 7)
- (format-time-string "%Y" time))))
+ (let ((system-time-locale "C"))
+ (format-time-string "%e-%b-%Y" (list high low))))
(defun archive-unixtime (low high)
"Stringify Unix (LOW HIGH) time."
diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index 0ac57e9..59a22f7 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -450,7 +450,7 @@ nnrss: %s: Not valid XML %s and libxml-parse-html-region
doesn't work %s"
This function handles the ISO 8601 date format described in
URL `https://www.w3.org/TR/NOTE-datetime', and also the RFC 822 style
which RSS 2.0 allows."
- (let (case-fold-search vector year month day time zone cts given)
+ (let (case-fold-search vector year month day time zone given)
(cond ((null date)) ; do nothing for this case
;; if the date is just digits (unix time stamp):
((string-match "^[0-9]+$" date)
@@ -481,13 +481,13 @@ which RSS 2.0 allows."
0
(decoded-time-zone decoded))))))
(if month
- (progn
- (setq cts (current-time-string (encode-time 0 0 0 day month year)))
- (format "%s, %02d %s %04d %s%s"
- (substring cts 0 3) day (substring cts 4 7) year time
- (if zone
- (concat " " (format-time-string "%z" nil zone))
- "")))
+ (concat (let ((system-time-locale "C"))
+ (format-time-string "%a, %d %b %Y "
+ (encode-time 0 0 0 day month year)))
+ time
+ (if zone
+ (format-time-string " %z" nil zone)
+ ""))
(message-make-date given))))
;;; data functions
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index db65561..0ca26f7 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -467,8 +467,8 @@ checksum before doing the check."
(defun tar-clip-time-string (time)
(declare (obsolete format-time-string "27.1"))
- (let ((str (current-time-string time)))
- (concat " " (substring str 4 16) (format-time-string " %Y" time))))
+ (let ((system-time-locale "C"))
+ (format-time-string " %b %e %H:%M %Y" time)))
(defun tar-grind-file-mode (mode)
"Construct a `rw-r--r--' string indicating MODE.
- master updated (e726a00 -> 9e131f5), Paul Eggert, 2021/12/16
- master cea0d61 4/9: Prefer format-time-string to current-time-string,
Paul Eggert <=
- master e0ca8f7 6/9: Prefer format-time-string to current-time-zone, Paul Eggert, 2021/12/16
- master 73d6b19 8/9: Omit temporary warning re obsolete timestamps, Paul Eggert, 2021/12/16
- master 34e3ad5 1/9: Fix encode-time doc string, Paul Eggert, 2021/12/16
- master fc520f8 5/9: Minor nndiary simplificatiuon with time zone, Paul Eggert, 2021/12/16
- master 3e6c69de 2/9: Fix icalendar time zone parsing glitch, Paul Eggert, 2021/12/16
- master dd0727e 3/9: encode-time simplifications, Paul Eggert, 2021/12/16
- master f25ad39 7/9: Assume current-time-zone exists, Paul Eggert, 2021/12/16
- master 9e131f5 9/9: Simplify epa-ks--parse-buffer timestamp handling, Paul Eggert, 2021/12/16