diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-22 01:04:36 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-22 01:07:32 -0700 |
commit | 3aee7be62eaf8caef6f2fab31bee79674b3abbb7 (patch) | |
tree | 29226a5776f2ded9966138b98b5cef15b50ce463 /lisp/ls-lisp.el | |
parent | 2bfa42855bf0278497f2e4540eac2086dab254c3 (diff) | |
download | emacs-3aee7be62eaf8caef6f2fab31bee79674b3abbb7.tar.gz |
Avoid unnecessary rounding errors in timestamps
Avoid the rounding errors of float-time when it’s easy. E.g.,
replace (< (float-time a) (float-time b)) with (time-less-p a b).
* lisp/desktop.el (desktop-save):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/epg.el (epg-wait-for-completion):
* lisp/files.el (dir-locals-find-file, dir-locals-read-from-dir):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-format-time):
* lisp/net/ange-ftp.el (ange-ftp-file-newer-than-file-p)
(ange-ftp-verify-visited-file-modtime):
* lisp/net/rcirc.el (rcirc-ctcp-sender-PING):
* lisp/textmodes/remember.el (remember-store-in-mailbox):
* lisp/url/url-cookie.el (url-cookie-expired-p):
Bypass float-time to avoid rounding errors.
* lisp/files.el (dir-locals-find-file):
Diffstat (limited to 'lisp/ls-lisp.el')
-rw-r--r-- | lisp/ls-lisp.el | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 280e7f4bc3e..66dddbbc17b 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el @@ -861,7 +861,7 @@ Use the same method as ls to decide whether to show time-of-day or year, depending on distance between file date and the current time. All ls time options, namely c, t and u, are handled." (let* ((time (nth (or time-index 5) file-attr)) ; default is last modtime - (diff (- (float-time time) (float-time))) + (diff (time-subtract time nil)) ;; Consider a time to be recent if it is within the past six ;; months. A Gregorian year has 365.2425 * 24 * 60 * 60 == ;; 31556952 seconds on the average, and half of that is 15778476. @@ -878,7 +878,8 @@ All ls time options, namely c, t and u, are handled." (if (member locale '("C" "POSIX")) (setq locale nil)) (format-time-string - (if (and (<= past-cutoff diff) (<= diff 0)) + (if (and (not (time-less-p diff past-cutoff)) + (not (time-less-p 0 diff))) (if (and locale (not ls-lisp-use-localized-time-format)) "%m-%d %H:%M" (nth 0 ls-lisp-format-time-list)) |