1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

Simplify a few timestamps

* lisp/calendar/time-date.el (safe-date-to-time):
* lisp/calendar/timeclock.el (timeclock-generate-report):
* lisp/epg.el (epg--start):
* lisp/gnus/gnus-demon.el (gnus-demon-nntp-close-connection):
* lisp/gnus/gnus-util.el (gnus-date-get-time):
* lisp/gnus/nnheader.el (nnheader-last-message-time):
* lisp/gnus/nnrss.el (nnrss-request-expire-articles):
* lisp/vc/ediff-util.el (ediff-command-begin-time)
(ediff-calc-command-time, ediff-profile):
Prefer an integer like 0 to a timestamp list like (0 0)
where either will do.
This commit is contained in:
Paul Eggert 2022-08-01 00:38:33 -07:00
parent d634cb0954
commit a51863f73d
8 changed files with 13 additions and 13 deletions

View File

@ -256,10 +256,10 @@ Returns a floating point number."
;;;###autoload ;;;###autoload
(defun safe-date-to-time (date) (defun safe-date-to-time (date)
"Parse a string DATE that represents a date-time and return a time value. "Parse a string DATE that represents a date-time and return a time value.
If DATE is malformed, return a time value of zeros." If DATE is malformed, return a time value of zero."
(condition-case () (condition-case ()
(date-to-time date) (date-to-time date)
(error '(0 0)))) (error 0)))
;;;###autoload ;;;###autoload

View File

@ -1247,7 +1247,7 @@ HTML-P is non-nil, HTML markup is added."
(time-out (vector (list t) (list t) (list t) (list t) (list t))) (time-out (vector (list t) (list t) (list t) (list t) (list t)))
(breaks (vector (list t) (list t) (list t) (list t) (list t))) (breaks (vector (list t) (list t) (list t) (list t) (list t)))
(workday (vector (list t) (list t) (list t) (list t) (list t))) (workday (vector (list t) (list t) (list t) (list t) (list t)))
(lengths (vector '(0 0) thirty-days-ago three-months-ago (lengths (vector 0 thirty-days-ago three-months-ago
six-months-ago one-year-ago))) six-months-ago one-year-ago)))
;; collect statistics from complete timelog ;; collect statistics from complete timelog
(dolist (day day-list) (dolist (day day-list)

View File

@ -606,7 +606,7 @@ callback data (if any)."
process process
terminal-name terminal-name
agent-file agent-file
(agent-mtime '(0 0 0 0))) (agent-mtime 0))
;; Set GPG_TTY and TERM for pinentry-curses. Note that we can't ;; Set GPG_TTY and TERM for pinentry-curses. Note that we can't
;; use `terminal-name' here to get the real pty name for the child ;; use `terminal-name' here to get the real pty name for the child
;; process, though /dev/fd/0" is not portable. ;; process, though /dev/fd/0" is not portable.
@ -633,7 +633,7 @@ callback data (if any)."
(setq agent-file (match-string 1 agent-info) (setq agent-file (match-string 1 agent-info)
agent-mtime (or (file-attribute-modification-time agent-mtime (or (file-attribute-modification-time
(file-attributes agent-file)) (file-attributes agent-file))
'(0 0 0 0)))) 0)))
(if epg-debug (if epg-debug
(save-excursion (save-excursion
(unless epg-debug-buffer (unless epg-debug-buffer

View File

@ -222,7 +222,7 @@ minutes, the connection is closed."
(defun gnus-demon-nntp-close-connection () (defun gnus-demon-nntp-close-connection ()
(save-window-excursion (save-window-excursion
(when (time-less-p '(0 300) (time-since nntp-last-command-time)) (when (time-less-p 300 (time-since nntp-last-command-time))
(nntp-close-server)))) (nntp-close-server))))
(defun gnus-demon-add-scanmail () (defun gnus-demon-add-scanmail ()

View File

@ -383,7 +383,7 @@ Cache the result as a text property stored in DATE."
;; Either return the cached value... ;; Either return the cached value...
`(let ((d ,date)) `(let ((d ,date))
(if (equal "" d) (if (equal "" d)
'(0 0) 0
(or (get-text-property 0 'gnus-time d) (or (get-text-property 0 'gnus-time d)
;; or compute the value... ;; or compute the value...
(let ((time (safe-date-to-time d))) (let ((time (safe-date-to-time d)))

View File

@ -1055,7 +1055,7 @@ See `find-file-noselect' for the arguments."
(or ,end (point-max))) (or ,end (point-max)))
'(buffer-string))))) '(buffer-string)))))
(defvar nnheader-last-message-time '(0 0)) (defvar nnheader-last-message-time 0)
(defun nnheader-message-maybe (&rest args) (defun nnheader-message-maybe (&rest args)
(let ((now (current-time))) (let ((now (current-time)))
(when (time-less-p 1 (time-subtract now nnheader-last-message-time)) (when (time-less-p 1 (time-subtract now nnheader-last-message-time))

View File

@ -325,7 +325,7 @@ for decoding when the cdr that the data specify is not available.")
(nnmail-expired-article-p (nnmail-expired-article-p
group group
(if (listp (setq days (nth 1 e))) days (if (listp (setq days (nth 1 e))) days
(days-to-time (- days (time-to-days '(0 0))))) (days-to-time (- days (time-to-days 0))))
force)) force))
(setq nnrss-group-data (delq e nnrss-group-data) (setq nnrss-group-data (delq e nnrss-group-data)
changed t) changed t)

View File

@ -4094,11 +4094,11 @@ Mail anyway? (y or n) ")
;;; Debug ;;; Debug
(ediff-defvar-local ediff-command-begin-time '(0 0 0)) (ediff-defvar-local ediff-command-begin-time 0)
;; calculate time used by command ;; calculate time used by command
(defun ediff-calc-command-time () (defun ediff-calc-command-time ()
(or (equal ediff-command-begin-time '(0 0 0)) (or (equal ediff-command-begin-time 0)
(message "Elapsed time: %g second(s)" (message "Elapsed time: %g second(s)"
(float-time (time-since ediff-command-begin-time))))) (float-time (time-since ediff-command-begin-time)))))
@ -4112,10 +4112,10 @@ Mail anyway? (y or n) ")
(let ((pre-hook 'pre-command-hook) (let ((pre-hook 'pre-command-hook)
(post-hook 'post-command-hook)) (post-hook 'post-command-hook))
(if (not (equal ediff-command-begin-time '(0 0 0))) (if (not (equal ediff-command-begin-time 0))
(progn (remove-hook pre-hook 'ediff-save-time) (progn (remove-hook pre-hook 'ediff-save-time)
(remove-hook post-hook 'ediff-calc-command-time) (remove-hook post-hook 'ediff-calc-command-time)
(setq ediff-command-begin-time '(0 0 0)) (setq ediff-command-begin-time 0)
(message "Ediff profiling disabled")) (message "Ediff profiling disabled"))
(add-hook pre-hook 'ediff-save-time t 'local) (add-hook pre-hook 'ediff-save-time t 'local)
(add-hook post-hook 'ediff-calc-command-time nil 'local) (add-hook post-hook 'ediff-calc-command-time nil 'local)