1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Don’t assume CURRENT_TIME_LIST

Use timestamp accessors instead of delving into a timestamp
format that is planned to change in a future version.
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
Use encode-time instead of delving into timestamp format.
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
Use float-time instead of delving into timestamp format.
* lisp/gnus/nnmaildir.el (nnmaildir-request-accept-article):
Use format-time-string instead of delving into timestamp format.
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
Use time-less-p instead of delving into timestamp format.
* lisp/ido.el (ido-wash-history, ido-file-name-all-completions):
Use time-equal-p instead of delving into timestamp format.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use format-time-string to generate POSIX ‘test -t’ format instead
of timestamp-format-dependent code along with shell arithmetic
that can’t possibly do the right thing on a POSIX platform.
This commit is contained in:
Paul Eggert 2019-02-10 23:46:24 -08:00
parent 988e37fa0f
commit 9324124253
7 changed files with 32 additions and 52 deletions

View file

@ -342,16 +342,11 @@ list of ls option letters of which c and u are recognized). Use
the same method as \"ls\" to decide whether to show time-of-day or
year, depending on distance between file date and NOW."
(let* ((time (nth (find-lisp-time-index switches) file-attr))
(diff16 (- (car time) (car now)))
(diff (+ (ash diff16 16) (- (car (cdr time)) (car (cdr now)))))
(past-cutoff (- (* 6 30 24 60 60))) ; 6 30-day months
(diff (encode-time (time-subtract time now) 'integer))
(past-cutoff -15778476) ; 1/2 of a Gregorian year
(future-cutoff (* 60 60))) ; 1 hour
(format-time-string
(if (and
(<= past-cutoff diff) (<= diff future-cutoff)
;; Sanity check in case `diff' computation overflowed.
(<= (1- (ash past-cutoff -16)) diff16)
(<= diff16 (1+ (ash future-cutoff -16))))
(if (<= past-cutoff diff future-cutoff)
"%b %e %H:%M"
"%b %e %Y")
time)))

View file

@ -4578,8 +4578,7 @@ and the second element is the address."
This function can be used in hooks like `gnus-select-group-hook'
or `gnus-group-catchup-group-hook'."
(when gnus-newsgroup-name
(let ((time (current-time)))
(setcdr (cdr time) nil)
(let ((time (encode-time nil 'integer)))
(gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
(defsubst gnus-group-timestamp (group)
@ -4588,11 +4587,11 @@ or `gnus-group-catchup-group-hook'."
(defun gnus-group-timestamp-delta (group)
"Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number."
(let* ((time (or (gnus-group-timestamp group)
(list 0 0)))
;; FIXME: This should return a Lisp integer, not a Lisp float,
;; since it is always an integer.
(let* ((time (or (gnus-group-timestamp group) 0))
(delta (time-subtract nil time)))
(+ (* (nth 0 delta) 65536.0)
(nth 1 delta))))
(float-time delta)))
(defun gnus-group-timestamp-string (group)
"Return a string of the timestamp for GROUP."

View file

@ -655,10 +655,7 @@ is searched."
(defun gnus-icalendar-show-org-agenda (event)
(let* ((time-delta (time-subtract (gnus-icalendar-event:end-time event)
(gnus-icalendar-event:start-time event)))
(duration-days (1+ (/ (+ (* (car time-delta) (expt 2 16))
(cadr time-delta))
86400))))
(duration-days (1+ (floor (encode-time time-delta 'integer) 86400))))
(org-agenda-list nil (gnus-icalendar-event:start event) duration-days)))
(cl-defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status)

View file

@ -1467,7 +1467,7 @@ This variable is set by `nnmaildir-request-article'.")
(unless (string-equal nnmaildir--delivery-time file)
(setq nnmaildir--delivery-time file
nnmaildir--delivery-count 0))
(setq file (concat file "M" (number-to-string (caddr time))))
(setq file (concat file (format-time-string "M%6N" time)))
(setq file (concat file nnmaildir--delivery-pid)
file (concat file "Q" (number-to-string nnmaildir--delivery-count))
file (concat file "." (nnmaildir--system-name))
@ -1553,7 +1553,7 @@ This variable is set by `nnmaildir-request-article'.")
(defun nnmaildir-request-expire-articles (ranges &optional gname server force)
(let ((no-force (not force))
(group (nnmaildir--prepare server gname))
pgname time boundary bound-iter high low target dir nlist
pgname time boundary high low target dir nlist
didnt nnmaildir--file nnmaildir-article-file-name
deactivate-mark)
(catch 'return
@ -1602,15 +1602,8 @@ This variable is set by `nnmaildir-request-article'.")
((null time)
(nnmaildir--expired-article group article))
((and no-force
(progn
(setq time (file-attribute-modification-time time)
bound-iter boundary)
(while (and bound-iter time
(= (car bound-iter) (car time)))
(setq bound-iter (cdr bound-iter)
time (cdr time)))
(and bound-iter time
(car-less-than-car bound-iter time))))
(time-less-p boundary
(file-attribute-modification-time time)))
(setq didnt (cons (nnmaildir--art-num article) didnt)))
(t
(setq nnmaildir-article-file-name nnmaildir--file

View file

@ -1515,20 +1515,20 @@ Removes badly formatted data and ignored directories."
(files (cdr (cdr (car l)))))
(and
(stringp dir)
(consp time)
(cond
((integerp (car time))
(and (not (zerop (float-time time)))
(ido-may-cache-directory dir)))
((eq (car time) 'ftp)
(and (numberp (cdr time))
(ido-is-ftp-directory dir)
(ido-cache-ftp-valid (cdr time))))
((eq (car time) 'unc)
(and (numberp (cdr time))
(ido-is-unc-host dir)
(ido-cache-unc-valid (cdr time))))
(t nil))
(if (condition-case nil
(not (time-equal-p time 0))
(error))
(ido-may-cache-directory dir)
(and
(consp time)
(numberp (cdr time))
(cond
((eq (car time) 'ftp)
(and (ido-is-ftp-directory dir)
(ido-cache-ftp-valid (cdr time))))
((eq (car time) 'unc)
(and (ido-is-unc-host dir)
(ido-cache-unc-valid (cdr time)))))))
(let ((s files) (ok t))
(while s
(if (stringp (car s))
@ -3621,8 +3621,7 @@ Uses and updates `ido-dir-file-cache'."
(ido-cache-unc-valid (cdr ctime)))))
(t
(if attr
(setq valid (and (= (car ctime) (car mtime))
(= (car (cdr ctime)) (car (cdr mtime))))))))
(setq valid (time-equal-p ctime mtime)))))
(unless valid
(setq ido-dir-file-cache (delq cached ido-dir-file-cache)
cached nil)))

View file

@ -679,9 +679,8 @@ But handle the case, if the \"test\" command is not available."
(current-time)
time)))
(tramp-adb-send-command-and-check
;; Use shell arithmetic because of Emacs integer size limit.
v (format "touch -t $(( %d * 65536 + %d )) %s"
(car time) (cadr time)
v (format "touch -t %s %s"
(format-time-string "%Y%m%d%H%M.%S" time)
(tramp-shell-quote-argument localname))))))
(defun tramp-adb-handle-copy-file

View file

@ -2010,10 +2010,8 @@ Optional argument REDRAW, if non-nil, forces mode line to be updated."
;; (after Man-bgproc-sentinel-advice activate)
;; ;; Terminates man processing
;; "Report formatting time."
;; (let* ((time (current-time))
;; (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536)
;; (- (cadr time) (cadr WoMan-Man-start-time)))))
;; (message "Man formatting done in %d seconds" time)))
;; (message "Man formatting done in %s seconds"
;; (float-time (time-subtract nil WoMan-Man-start-time))))
;;; Buffer handling: