summaryrefslogtreecommitdiff
path: root/lisp/time.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/time.el')
-rw-r--r--lisp/time.el47
1 files changed, 18 insertions, 29 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 953e6084e29..35157c5e807 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -336,15 +336,10 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'."
(next-time (timer-relative-time
(list (aref timer 1) (aref timer 2) (aref timer 3))
(* 5 (aref timer 4)) 0)))
- ;; If the activation time is far in the past,
+ ;; If the activation time is not in the future,
;; skip executions until we reach a time in the future.
;; This avoids a long pause if Emacs has been suspended for hours.
- (or (> (nth 0 next-time) (nth 0 current))
- (and (= (nth 0 next-time) (nth 0 current))
- (> (nth 1 next-time) (nth 1 current)))
- (and (= (nth 0 next-time) (nth 0 current))
- (= (nth 1 next-time) (nth 1 current))
- (> (nth 2 next-time) (nth 2 current)))
+ (or (time-less-p current next-time)
(progn
(timer-set-time timer (timer-next-integral-multiple-of-time
current display-time-interval)
@@ -365,7 +360,8 @@ Switches from the 1 to 5 to 15 minute load average, and then back to 1."
(while (and mail-files (= size 0))
;; Count size of regular files only.
(setq size (+ size (or (and (file-regular-p (car mail-files))
- (nth 7 (file-attributes (car mail-files))))
+ (file-attribute-size
+ (file-attributes (car mail-files))))
0)))
(setq mail-files (cdr mail-files)))
(if (> size 0)
@@ -438,23 +434,17 @@ update which can wait for the next redisplay."
((and (stringp mail-spool-file)
(or (null display-time-server-down-time)
;; If have been down for 20 min, try again.
- (> (- (nth 1 now) display-time-server-down-time)
- 1200)
- (and (< (nth 1 now) display-time-server-down-time)
- (> (- (nth 1 now)
- display-time-server-down-time)
- -64336))))
+ (time-less-p 1200 (time-since
+ display-time-server-down-time))))
(let ((start-time (current-time)))
(prog1
(display-time-file-nonempty-p mail-spool-file)
- (if (> (- (nth 1 (current-time))
- (nth 1 start-time))
- 20)
- ;; Record that mail file is not accessible.
- (setq display-time-server-down-time
- (nth 1 (current-time)))
- ;; Record that mail file is accessible.
- (setq display-time-server-down-time nil)))))))
+ ;; Record whether mail file is accessible.
+ (setq display-time-server-down-time
+ (let ((end-time (current-time)))
+ (and (time-less-p 20 (time-subtract
+ end-time start-time))
+ (float-time end-time)))))))))
(24-hours (substring time 11 13))
(hour (string-to-number 24-hours))
(12-hours (int-to-string (1+ (% (+ hour 11) 12))))
@@ -483,14 +473,12 @@ update which can wait for the next redisplay."
(defun display-time-file-nonempty-p (file)
(let ((remote-file-name-inhibit-cache (- display-time-interval 5)))
(and (file-exists-p file)
- (< 0 (nth 7 (file-attributes (file-chase-links file)))))))
+ (< 0 (file-attribute-size
+ (file-attributes (file-chase-links file)))))))
;;;###autoload
(define-minor-mode display-time-mode
"Toggle display of time, load level, and mail flag in mode lines.
-With a prefix argument ARG, enable Display Time mode if ARG is
-positive, and disable it otherwise. If called from Lisp, enable
-it if ARG is omitted or nil.
When Display Time mode is enabled, it updates every minute (you
can control the number of seconds between updates by customizing
@@ -584,8 +572,9 @@ For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
(interactive)
(let ((str
(format-seconds (or format "%Y, %D, %H, %M, %z%S")
- (float-time
- (time-subtract (current-time) before-init-time)))))
+ (encode-time
+ (time-since before-init-time)
+ 'integer))))
(if (called-interactively-p 'interactive)
(message "%s" str)
str)))
@@ -595,7 +584,7 @@ For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
"Return a string giving the duration of the Emacs initialization."
(interactive)
(let ((str
- (format "%.1f seconds"
+ (format "%s seconds"
(float-time
(time-subtract after-init-time before-init-time)))))
(if (called-interactively-p 'interactive)