last-full-capacity design-capacity))
(and capacity rate
(setq minutes (if (zerop rate) 0
- (floor (* (/ (float (if (string= charging-state
- "charging")
- (- full-capacity capacity)
- capacity))
- rate)
- 60)))
+ (floor (* (if (string= charging-state
+ "charging")
+ (- full-capacity capacity)
+ capacity)
+ 60)
+ rate))
hours (/ minutes 60)))
(list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
(cons ?L (or (battery-search-for-one-match-in-files
(cons ?p (or (and full-capacity capacity
(> full-capacity 0)
(number-to-string
- (floor (/ capacity
- (/ (float full-capacity) 100)))))
+ (floor (* 100 capacity) full-capacity)))
"N/A")))))
\f
"POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$"
nil t)
(cl-incf power-now
- (* (float (string-to-number (match-string 2)))
+ (* (string-to-number (match-string 2))
(if (eq (char-after (match-beginning 1)) ?C)
- voltage-now 1.0))))
+ voltage-now 1))))
(goto-char (point-min))
(when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t)
(setq temperature (match-string 1)))
(when seconds
(setq minutes (/ seconds 60)
hours (/ minutes 60)
- remaining-time
- (format "%d:%02d" (truncate hours)
- (- (truncate minutes) (* 60 (truncate hours))))))
+ remaining-time (format "%d:%02d" hours (mod minutes 60))))
(list (cons ?c (or (and energy
(number-to-string (round (* 1000 energy))))
"N/A"))
(setq minutes (string-to-number battery-life)
seconds (* 60 minutes))
(setq seconds (string-to-number battery-life)
- minutes (truncate (/ seconds 60))))
- (setq hours (truncate (/ minutes 60))
- remaining-time (format "%d:%02d" hours
- (- minutes (* 60 hours)))))
+ minutes (truncate seconds 60)))
+ (setq hours (truncate minutes 60)
+ remaining-time (format "%d:%02d" hours (mod minutes 60))))
(list (cons ?L (or line-status "N/A"))
(cons ?B (or (car battery-status) "N/A"))
(cons ?b (or (cdr battery-status) "N/A"))
;; https://lists.gnu.org/r/emacs-pretest-bug/2006-11/msg00060.html
(defun calendar-dst-find-data (&optional time)
"Find data on the first daylight saving time transitions after TIME.
-TIME defaults to `current-time'. Return value is as described
+TIME defaults to the current time. Return value is as described
for `calendar-current-time-zone'."
(let* ((t0 (or time (current-time)))
(t0-zone (current-time-zone t0))
(setq year (nth 2 mdy))))
;; create the decoded date-time
;; FIXME!?!
- (condition-case nil
- (decode-time (encode-time second minute hour day month year zone))
- (error
- (message "Cannot decode \"%s\"" isodatetimestring)
- ;; hope for the best...
- (list second minute hour day month year 0 nil 0))))
+ (let ((decoded-time (list second minute hour day month year
+ nil -1 zone)))
+ (condition-case nil
+ (decode-time (encode-time decoded-time 'integer))
+ (error
+ (message "Cannot decode \"%s\"" isodatetimestring)
+ ;; Hope for the best....
+ decoded-time))))
;; isodatetimestring == nil
nil))
ENTRY-MAIN is the first line of the diary entry.
Optional argument START determines the first day of the
-enumeration, given as a time value, in same format as returned by
-`current-time' -- used for test purposes."
+enumeration, given as a Lisp time value -- used for test purposes."
(cond ((string-match (concat nonmarker
"%%(and \\(([^)]+)\\))\\(\\s-*.*?\\) ?$")
entry-main)
(mapcar
(lambda (offset)
(let* ((day (decode-time (time-add now
- (encode-time
- (* offset 60 60 24)))))
+ (* 60 60 24 offset))))
(d (nth 3 day))
(m (nth 4 day))
(y (nth 5 day))
output a \"+\" if the time value is negative, rather than a \"-\".
This is used when negative time values have an inverted meaning (such
as with time remaining, where negative time really means overtime)."
- (if show-seconds
- (format "%s%d:%02d:%02d"
- (if (< seconds 0) (if reverse-leader "+" "-") "")
- (truncate (/ (abs seconds) 60 60))
- (% (truncate (/ (abs seconds) 60)) 60)
- (% (truncate (abs seconds)) 60))
- (format "%s%d:%02d"
+ (let ((s (abs (truncate seconds))))
+ (format (if show-seconds "%s%d:%02d:%02d" "%s%d:%02d")
(if (< seconds 0) (if reverse-leader "+" "-") "")
- (truncate (/ (abs seconds) 60 60))
- (% (truncate (/ (abs seconds) 60)) 60))))
+ (/ s 3600) (% (/ s 60) 60) (% s 60))))
(defsubst timeclock-currently-in-p ()
"Return non-nil if the user is currently clocked in."
"Return a time value representing the end of today's workday.
If TODAY-ONLY is non-nil, the value returned will be relative only to
the time worked today, and not to past time."
- (time-subtract nil
- (let ((discrep (timeclock-find-discrep)))
- (if discrep
- (if today-only
- (cadr discrep)
- (car discrep))
- 0))))
+ (time-since (let ((discrep (timeclock-find-discrep)))
+ (if discrep
+ (if today-only
+ (cadr discrep)
+ (car discrep))
+ 0))))
;;;###autoload
(defun timeclock-when-to-leave-string (&optional show-seconds
"\n")
(if (equal (downcase code) "o")
(setq timeclock-last-period
- (- (float-time now)
- (float-time (cadr timeclock-last-event)))
+ (float-time
+ (time-subtract now (cadr timeclock-last-event)))
timeclock-discrepancy
(+ timeclock-discrepancy
timeclock-last-period)))
This is only provided for coherency when used by
`timeclock-discrepancy'."
(if (equal (car timeclock-last-event) "i")
- (- (float-time moment)
- (float-time (cadr timeclock-last-event)))
+ (float-time (time-subtract moment (cadr timeclock-last-event)))
timeclock-last-period))
(cl-defstruct (timeclock-entry
(defsubst timeclock-entry-length (entry)
"Return the length of ENTRY in seconds."
- (- (float-time (cadr entry))
- (float-time (car entry))))
+ (float-time (time-subtract (cadr entry) (car entry))))
(defsubst timeclock-entry-list-length (entry-list)
"Return the total length of ENTRY-LIST in seconds."
(defsubst timeclock-entry-list-span (entry-list)
"Return the total time in seconds spanned by ENTRY-LIST."
- (- (float-time (timeclock-entry-list-end entry-list))
- (float-time (timeclock-entry-list-begin entry-list))))
+ (float-time (time-subtract (timeclock-entry-list-end entry-list)
+ (timeclock-entry-list-begin entry-list))))
(defsubst timeclock-entry-list-break (entry-list)
"Return the total break time (span - length) in ENTRY-LIST."
last-date-limited nil)
(if beg
(error "Error in format of timelog file!")
- (setq beg (float-time (cadr event))))))
+ (setq beg (cadr event)))))
((equal (downcase (car event)) "o")
(if (and (nth 2 event)
(> (length (nth 2 event)) 0))
(if (not beg)
(error "Error in format of timelog file!")
(setq timeclock-last-period
- (- (float-time (cadr event)) beg)
+ (float-time (time-subtract (cadr event) beg))
accum (+ timeclock-last-period accum)
beg nil))
(if (equal last-date todays-date)
(unless (time-less-p
(timeclock-day-begin day)
(aref lengths i))
- (let ((base (float-time
- (timeclock-day-base
- (timeclock-day-begin day)))))
+ (let ((base (timeclock-day-base (timeclock-day-begin day))))
(nconc (aref time-in i)
- (list (- (float-time (timeclock-day-begin day))
- base)))
+ (list (float-time (time-subtract
+ (timeclock-day-begin day)
+ base))))
(let ((span (timeclock-day-span day))
(len (timeclock-day-length day))
(req (timeclock-day-required day)))
(when (and (> span 0)
(> (/ (float len) (float span)) 0.70))
(nconc (aref time-out i)
- (list (- (float-time (timeclock-day-end day))
- base)))
+ (list (float-time (time-subtract
+ (timeclock-day-end day)
+ base))))
(nconc (aref breaks i) (list (- span len))))
(if req
(setq len (+ len (- timeclock-workday req))))
(ans (ede-detect-directory-for-project default-directory)))
(if ans
(message "Project found in %d sec @ %s of type %s"
- (float-time (time-subtract nil start))
+ (encode-time (time-since start) 'integer)
(car ans)
(eieio-object-name-string (cdr ans)))
(message "No Project found.") )))
\f
(defun cmpl-hours-since-origin ()
- (floor (float-time) 3600))
+ (floor (encode-time nil 'integer) 3600))
\f
;;---------------------------------------------------------------------------
;; "Symbol" parsing functions
;; for the sake of `clean-buffer-list': preserving the invariant
;; "how much time the user spent in Emacs without looking at this buffer".
(setq buffer-display-time
- (if buffer-display-time
- (time-add buffer-display-time
- (time-subtract nil desktop-file-modtime))
- (current-time)))
+ (time-since (if buffer-display-time
+ (time-subtract desktop-file-modtime
+ buffer-display-time)
+ 0)))
(unless (< desktop-file-version 208) ; Don't misinterpret any old custom args
(dolist (record compacted-vars)
(let*
(defun ecomplete-decay-1 (elem)
;; We subtract 5% from the item for each week it hasn't been used.
(/ (car elem)
- (expt 1.05 (/ (- (float-time) (cadr elem))
+ (expt 1.05 (/ (float-time (time-since (cadr elem)))
(* 7 24 60 60)))))
;; `ecomplete-get-matches' uses substring matching, so also use the `substring'
`(let (,t1)
(setq ,t1 (current-time))
,@forms
- (float-time (time-subtract nil ,t1)))))
+ (float-time (time-since ,t1)))))
;;;###autoload
(defmacro benchmark-run (&optional repetitions &rest forms)
(force-mode-line-update)
(redisplay t)
(setf (ert--stats-next-redisplay stats)
- (+ (float-time) ert-test-run-redisplay-interval-secs)))
+ (float-time (time-add nil ert-test-run-redisplay-interval-secs))))
(defun ert--results-update-stats-display-maybe (ewoc stats)
"Call `ert--results-update-stats-display' if not called recently.
EWOC and STATS are arguments for `ert--results-update-stats-display'."
- (when (>= (float-time) (ert--stats-next-redisplay stats))
+ (unless (time-less-p nil (ert--stats-next-redisplay stats))
(ert--results-update-stats-display ewoc stats)))
(defun ert--tests-running-mode-line-indicator ()
;; Idle.
(if (aref timer 7) "*" " ")
;; Next time.
- (let ((time (float-time (list (aref timer 1)
- (aref timer 2)
- (aref timer 3)))))
+ (let ((time (list (aref timer 1)
+ (aref timer 2)
+ (aref timer 3))))
(format "%.2f"
- (if (aref timer 7)
- time
- (- (float-time (list (aref timer 1)
- (aref timer 2)
- (aref timer 3)))
- (float-time)))))
+ (float-time
+ (if (aref timer 7)
+ time
+ (time-subtract time nil)))))
;; Repeat.
(let ((repeat (aref timer 4)))
(cond
(defun timer-set-time (timer time &optional delta)
"Set the trigger time of TIMER to TIME.
-TIME must be in the internal format returned by, e.g., `current-time'.
+TIME must be a Lisp time value.
If optional third argument DELTA is a positive number, make the timer
fire repeatedly that many seconds apart."
(setf (timer--time timer) time)
(defun timer-until (timer time)
"Calculate number of seconds from when TIMER will run, until TIME.
TIMER is a timer, and stands for the time when its next repeat is scheduled.
-TIME is a time-list."
- (- (float-time time) (float-time (timer--time timer))))
+TIME is a Lisp time value."
+ (float-time (time-subtract time (timer--time timer))))
(defun timer-event-handler (timer)
"Call the handler for the timer TIMER.
;; perhaps because Emacs was suspended for a long time,
;; limit how many times things get repeated.
(if (and (numberp timer-max-repeats)
- (< 0 (timer-until timer nil)))
+ (time-less-p nil (timer--time timer)))
(let ((repeats (/ (timer-until timer nil)
(timer--repeat-delay timer))))
(if (> repeats timer-max-repeats)
erc-server-last-received-time))
(with-current-buffer buf
(if (and erc-server-send-ping-timeout
- (>
- (erc-time-diff (erc-current-time)
- erc-server-last-received-time)
- erc-server-send-ping-timeout))
+ (time-less-p
+ erc-server-send-ping-timeout
+ (time-since erc-server-last-received-time)))
(progn
;; if the process is hung, kill it
(setq erc-server-timed-out t)
See `erc-server-flood-margin' for an explanation of the flood
protection algorithm."
(with-current-buffer buffer
- (let ((now (erc-current-time)))
+ (let ((now (current-time)))
(when erc-server-flood-timer
(erc-cancel-timer erc-server-flood-timer)
(setq erc-server-flood-timer nil))
- (when (< erc-server-flood-last-message
- now)
- (setq erc-server-flood-last-message now))
+ (when (time-less-p erc-server-flood-last-message now)
+ (setq erc-server-flood-last-message (erc-emacs-time-to-erc-time now)))
(while (and erc-server-flood-queue
- (< erc-server-flood-last-message
- (+ now erc-server-flood-margin)))
+ (time-less-p erc-server-flood-last-message
+ (time-add now erc-server-flood-margin)))
(let ((msg (caar erc-server-flood-queue))
(encoding (cdar erc-server-flood-queue)))
(setq erc-server-flood-queue (cdr erc-server-flood-queue)
erc-server-prevent-duplicates)
(let ((m (erc-response.unparsed parsed-response)))
;; duplicate suppression
- (if (< (or (gethash m erc-server-duplicates) 0)
- (- (erc-current-time) erc-server-duplicate-timeout))
+ (if (time-less-p (or (gethash m erc-server-duplicates) 0)
+ (time-since erc-server-duplicate-timeout))
(erc-call-hooks process parsed-response))
(puthash m (erc-current-time) erc-server-duplicates))
;; Hand off to the relevant handler.
"Handle pong messages." nil
(let ((time (string-to-number (erc-response.contents parsed))))
(when (> time 0)
- (setq erc-server-lag (erc-time-diff time (erc-current-time)))
+ (setq erc-server-lag (erc-time-diff time nil))
(when erc-verbose-server-ping
(erc-display-message
parsed 'notice proc 'PONG
(cdr (erc-response.command-args parsed))))
(setq time (when on-since
(format-time-string erc-server-timestamp-format
- (erc-string-to-emacs-time on-since))))
+ (string-to-number on-since))))
(erc-update-user-nick nick nick nil nil nil
(and time (format "on since %s" time)))
(if time
(define-erc-response-handler (329)
"Channel creation date." nil
(let ((channel (cadr (erc-response.command-args parsed)))
- (time (erc-string-to-emacs-time
+ (time (string-to-number
(nth 2 (erc-response.command-args parsed)))))
(erc-display-message
parsed 'notice (erc-get-buffer channel proc)
(pcase-let ((`(,channel ,nick ,time)
(cdr (erc-response.command-args parsed))))
(setq time (format-time-string erc-server-timestamp-format
- (erc-string-to-emacs-time time)))
+ (string-to-number time)))
(erc-update-channel-topic channel
(format "\C-o (%s, %s)" nick time)
'append)
?s (number-to-string erc-dcc-byte-count)
?t (format "%.0f"
(erc-time-diff (plist-get erc-dcc-entry-data :start-time)
- (erc-current-time)))))
+ nil))))
(kill-buffer (process-buffer proc))
(delete-process proc))
'timestamp))))
(away-time (erc-emacs-time-to-erc-time (erc-away-time))))
(when (and away-time last-msg-time
- (erc-time-gt last-msg-time away-time))
+ (time-less-p away-time last-msg-time))
(erc-display-message
nil 'notice 'active
(format "You have logged messages waiting in \"%s\"."
(if erc-track-when-inactive
(when erc-buffer-activity; could be nil
(and (erc-track-get-buffer-window buffer erc-track-visibility)
- (<= (erc-time-diff erc-buffer-activity (erc-current-time))
- erc-buffer-activity-timeout)))
+ (not (time-less-p erc-buffer-activity-timeout
+ (erc-time-diff erc-buffer-activity nil)))))
(erc-track-get-buffer-window buffer erc-track-visibility)))
;;; Tracking the channel modifications
(maphash
(lambda (nick last-PRIVMSG-time)
(when
- (> (float-time (time-subtract nil last-PRIVMSG-time))
- erc-lurker-threshold-time)
+ (time-less-p erc-lurker-threshold-time
+ (time-since last-PRIVMSG-time))
(remhash nick hash)))
hash)
(if (zerop (hash-table-count hash))
(gethash (erc-lurker-maybe-trim nick)
(gethash server erc-lurker-state (make-hash-table)))))
(or (null last-PRIVMSG-time)
- (> (float-time
- (time-subtract nil last-PRIVMSG-time))
- erc-lurker-threshold-time))))
+ (time-less-p erc-lurker-threshold-time
+ (time-since last-PRIVMSG-time)))))
(defcustom erc-common-server-suffixes
'(("openprojects.net\\'" . "OPN")
(defun erc-cmd-PING (recipient)
"Ping RECIPIENT."
- (let ((time (format "%f" (erc-current-time))))
+ (let ((time (format-time-string "%s.%6N")))
(erc-log (format "cmd: PING: %s" time))
(erc-cmd-CTCP recipient "PING" time)))
(user-full-name)
(user-login-name)
(system-name))))
- (ns (erc-time-diff erc-server-last-sent-time (erc-current-time))))
+ (ns (erc-time-diff erc-server-last-sent-time nil)))
(when (> ns 0)
(setq s (concat s " Idle for " (erc-sec-to-time ns))))
(erc-send-ctcp-notice nick s)))
nil
(let ((time (match-string 1 msg)))
(condition-case nil
- (let ((delta (erc-time-diff (string-to-number time)
- (erc-current-time))))
+ (let ((delta (erc-time-diff (string-to-number time) nil)))
(erc-display-message
nil 'notice 'active
'CTCP-PING ?n nick
(erc-default-target)
(if away-time
(format "is back (gone for %s)"
- (erc-sec-to-time
- (erc-time-diff
- (erc-emacs-time-to-erc-time away-time)
- (erc-current-time))))
+ (erc-sec-to-time (erc-time-diff away-time nil)))
"is back")))))))))
(erc-update-mode-line)))
(defun erc-send-current-line ()
"Parse current line and send it to IRC."
(interactive)
- (let ((now (float-time)))
+ (let ((now (current-time)))
(if (or (not erc-accidental-paste-threshold-seconds)
- (< erc-accidental-paste-threshold-seconds
- (- now erc-last-input-time)))
+ (time-less-p erc-accidental-paste-threshold-seconds
+ (time-subtract now erc-last-input-time)))
(save-restriction
(widen)
(if (< (point) (erc-beg-of-input-line))
;; time routines
-(defun erc-string-to-emacs-time (string)
- "Convert the long number represented by STRING into an Emacs timestamp."
- (let* ((n (string-to-number (concat string ".0"))))
- (list (truncate (/ n 65536))
- (truncate (mod n 65536)))))
+(define-obsolete-function-alias 'erc-string-to-emacs-time 'string-to-number
+ "27.1")
(defalias 'erc-emacs-time-to-erc-time 'float-time)
(defalias 'erc-current-time 'float-time)
(defun erc-time-diff (t1 t2)
- "Return the time difference in seconds between T1 and T2."
- (abs (- t2 t1)))
+ "Return the absolute value of the difference in seconds between T1 and T2."
+ (abs (float-time (time-subtract t1 t2))))
(defun erc-time-gt (t1 t2)
"Check whether T1 > T2."
- (> t1 t2))
+ (declare (obsolete time-less-p "27.1"))
+ (time-less-p t2 t1))
(defun erc-sec-to-time (ns)
"Convert NS to a time string HH:MM.SS."
(forward-char))
(if (looking-at "[0-9]+")
(progn
- (setq when (- (float-time)
- (* (string-to-number (match-string 0))
- quantum)))
+ (setq when (time-since (* (string-to-number (match-string 0))
+ quantum)))
(goto-char (match-end 0)))
(setq open (char-after))
(if (setq close (memq open '(?\( ?\[ ?\< ?\{)))
(attrs (file-attributes file)))
(unless attrs
(error "Cannot stat file `%s'" file))
- (setq when (float-time (nth attr-index attrs))))
+ (setq when (nth attr-index attrs)))
(goto-char (1+ end)))
`(lambda (file)
(let ((attrs (file-attributes file)))
(if attrs
(,(if (eq qual ?-)
- '<
+ 'time-less-p
(if (eq qual ?+)
- '>
- '=)) ,when (float-time
- (nth ,attr-index attrs))))))))
+ '(lambda (a b) (time-less-p b a))
+ 'time-equal-p))
+ ,when (nth ,attr-index attrs)))))))
(defun eshell-pred-file-type (type)
"Return a test which tests that the file is of a certain TYPE.
(defvar eshell-time-start nil)
(defun eshell-show-elapsed-time ()
- (let ((elapsed (format "%.3f secs\n" (- (float-time) eshell-time-start))))
+ (let ((elapsed (format "%.3f secs\n"
+ (float-time (time-since eshell-time-start)))))
(set-text-properties 0 (length elapsed) '(face bold) elapsed)
(eshell-interactive-print elapsed))
(remove-hook 'eshell-post-command-hook 'eshell-show-elapsed-time t))
(defun article-lapsed-string (time &optional max-segments)
;; If the date is seriously mangled, the timezone functions are
;; liable to bug out, so we ignore all errors.
- (let* ((real-time (time-subtract nil time))
+ (let* ((real-time (time-since time))
(real-sec (float-time real-time))
(sec (abs real-sec))
(segments 0)
(defun gnus-demon-idle-since ()
"Return the number of seconds since when Emacs is idle."
- (float-time (or (current-idle-time) '(0 0 0))))
+ (float-time (or (current-idle-time) 0)))
(defun gnus-demon-run-callback (func &optional idle time special)
"Run FUNC if Emacs has been idle for longer than IDLE seconds.
;; 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)))
+ (delta (time-since time)))
(float-time delta)))
(defun gnus-group-timestamp-string (group)
(end-time (format-time-string "%H:%M" end))
(end-at-midnight (string= end-time "00:00"))
(start-end-date-diff
- (/ (float-time (time-subtract
- (org-time-string-to-time end-date)
- (org-time-string-to-time start-date)))
- 86400))
+ (time-to-number-of-days (time-subtract
+ (org-time-string-to-time end-date)
+ (org-time-string-to-time start-date))))
(org-repeat (gnus-icalendar-event:org-repeat event))
(repeat (if org-repeat (concat " " org-repeat) ""))
- (time-1-day '(0 86400)))
+ (time-1-day 86400))
;; NOTE: special care is needed with appointments ending at midnight
;; (typically all-day events): the end time has to be changed to 23:59 to
(insert (format-time-string "%H:%M:%S")
(format " %.2fs %s %S\n"
(if (numberp gnus-backend-trace-elapsed)
- (- (float-time) gnus-backend-trace-elapsed)
+ (float-time
+ (time-since gnus-backend-trace-elapsed))
0)
type form))
(setq gnus-backend-trace-elapsed (float-time)))))
(when (and gnus-summary-default-score
scores)
(let* ((entries gnus-header-index)
- (now (time-to-days (current-time)))
+ (now (time-to-days nil))
(expire (and gnus-score-expiry-days
(- now gnus-score-expiry-days)))
(headers gnus-newsgroup-headers)
(memq 'word gnus-newsgroup-adaptive))
(with-temp-buffer
(let* ((hashtb (gnus-make-hashtable 1000))
- (date (time-to-days (current-time)))
+ (date (time-to-days nil))
(data gnus-newsgroup-data)
word d score val)
(with-syntax-table gnus-adaptive-word-syntax-table
Returns \" ? \" if there's bad input or if another error occurs.
Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
(condition-case ()
- (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
- (now (float-time))
+ (let* ((messy-date (gnus-date-get-time messy-date))
+ (now (current-time))
;;If we don't find something suitable we'll use this one
(my-format "%b %d '%y"))
- (let* ((difference (- now messy-date))
+ (let* ((difference (time-subtract now messy-date))
(templist gnus-user-date-format-alist)
(top (eval (caar templist))))
- (while (if (numberp top) (< top difference) (not top))
+ (while (if (numberp top) (time-less-p top difference) (not top))
(progn
(setq templist (cdr templist))
(setq top (eval (caar templist)))))
(if (stringp (cdr (car templist)))
(setq my-format (cdr (car templist)))))
- (format-time-string (eval my-format) (encode-time messy-date)))
+ (format-time-string (eval my-format) messy-date))
(error " ? ")))
(defun gnus-summary-set-local-parameters (group)
"Return the highest article date in THREAD."
(apply 'max
(mapcar (lambda (header) (float-time
- (gnus-date-get-time
- (mail-header-date header))))
+ (gnus-date-get-time
+ (mail-header-date header))))
(flatten-tree thread))))
(defun gnus-thread-total-score-1 (root)
;; Don't check for old incoming files more than once per day to
;; save a lot of file accesses.
(when (or (null mail-source-incoming-last-checked-time)
- (> (float-time
- (time-since mail-source-incoming-last-checked-time))
- (* 24 60 60)))
+ (time-less-p
+ (* 24 60 60)
+ (time-since mail-source-incoming-last-checked-time)))
(setq mail-source-incoming-last-checked-time (current-time))
(mail-source-delete-old-incoming
mail-source-delete-incoming
"Subject: " (file-name-nondirectory file) (or extra-msg "") "\n"
"Message-ID: <nneething-" (nneething-encode-file-name file)
"@" (system-name) ">\n"
- (if (zerop (float-time (file-attribute-modification-time atts))) ""
+ (if (time-equal-p 0 (file-attribute-modification-time atts)) ""
(concat "Date: "
(current-time-string (file-attribute-modification-time atts))
"\n"))
(defvar nnheader-last-message-time '(0 0))
(defun nnheader-message-maybe (&rest args)
(let ((now (current-time)))
- (when (> (float-time (time-subtract now nnheader-last-message-time)) 1)
+ (when (time-less-p 1 (time-subtract now nnheader-last-message-time))
(setq nnheader-last-message-time now)
(apply 'nnheader-message args))))
(with-current-buffer buffer
(when (and nnimap-object
(nnimap-last-command-time nnimap-object)
- (> (float-time
- (time-subtract
- now
- (nnimap-last-command-time nnimap-object)))
- ;; More than five minutes since the last command.
- (* 5 60)))
+ (time-less-p
+ ;; More than five minutes since the last command.
+ (* 5 60)
+ (time-subtract
+ now
+ (nnimap-last-command-time nnimap-object))))
(ignore-errors ;E.g. "buffer foo has no process".
(nnimap-send-command "NOOP"))))))))
(setq days (days-to-time days))
;; Compare the time with the current time.
(if (null time)
- (time-subtract nil days)
+ (time-since days)
(ignore-errors (time-less-p days (time-since time)))))))))
(declare-function gnus-group-mark-article-read "gnus-group" (group article))
(defun nnmaildir--scan (gname scan-msgs groups _method srv-dir srv-ls)
(catch 'return
- (let ((36h-ago (- (float-time) 129600))
+ (let ((36h-ago (time-since 129600))
absdir nndir tdir ndir cdir nattr cattr isnew pgname read-only ls
files num dir flist group x)
(setq absdir (nnmaildir--srvgrp-dir srv-dir gname)
(when no-force
(unless (integerp time) ;; handle 'never
(throw 'return (gnus-uncompress-range ranges)))
- (setq boundary (time-subtract nil time)))
+ (setq boundary (time-since time)))
(setq dir (nnmaildir--srv-dir nnmaildir--cur-server)
dir (nnmaildir--srvgrp-dir dir gname)
dir (nnmaildir--cur dir)
(ibuffer-mark-on-buffer
#'(lambda (buf)
(with-current-buffer buf
- ;; hacked from midnight.el
(when buffer-display-time
- (let* ((now (float-time))
- (then (float-time buffer-display-time)))
- (> (- now then) (* 60 60 ibuffer-old-time))))))))
+ (time-less-p
+ (* 60 60 ibuffer-old-time)
+ (time-since buffer-display-time)))))))
;;;###autoload
(defun ibuffer-mark-special-buffers ()
for the animation speed. A negative value means to animate in reverse."
(when (and (buffer-live-p (plist-get (cdr image) :animate-buffer))
;; Delayed more than two seconds more than expected.
- (or (<= (- (float-time) target-time) 2)
+ (or (time-less-p (time-since target-time) 2)
(progn
(message "Stopping animation; animation possibly too big")
nil)))
(image-show-frame image n t)
(let* ((speed (image-animate-get-speed image))
- (time (float-time))
+ (time (current-time))
(animation (image-multi-frame-p image))
+ (time-to-load-image (time-since time))
+ (stated-delay-time (/ (or (cdr animation)
+ image-default-frame-delay)
+ (float (abs speed))))
;; Subtract off the time we took to load the image from the
;; stated delay time.
- (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
- (/ 1.0 (abs speed)))
- time (- (float-time)))
+ (delay (max (float-time (time-subtract stated-delay-time
+ time-to-load-image))
image-minimum-frame-delay))
done)
(setq n (if (< speed 0)
(defun feedmail-rfc822-date (arg-time)
(feedmail-say-debug ">in-> feedmail-rfc822-date %s" arg-time)
- (let ((time (if arg-time arg-time (current-time)))
+ (let ((time (or arg-time (current-time)))
(system-time-locale "C"))
(concat
(format-time-string "%a, %e %b %Y %T " time)
(defun mouse--down-1-maybe-follows-link (&optional _prompt)
(when mouse-1-click-follows-link
- (setq mouse--last-down (cons (car-safe last-input-event) (float-time))))
+ (setq mouse--last-down (cons (car-safe last-input-event) (current-time))))
nil)
(defun mouse--click-1-maybe-follows-link (&optional _prompt)
('double (eq 'double-mouse-1 (car-safe last-input-event)))
(_ (and (eq 'mouse-1 (car-safe last-input-event))
(or (not (numberp mouse-1-click-follows-link))
- (funcall (if (< mouse-1-click-follows-link 0) #'> #'<)
- (- (float-time) (cdr mouse--last-down))
+ (funcall (if (< mouse-1-click-follows-link 0)
+ (lambda (a b) (time-less-p b a))
+ #'time-less-p)
+ (time-since (cdr mouse--last-down))
(/ (abs mouse-1-click-follows-link) 1000.0))))))
(eq (car mouse--last-down)
(event-convert-list (list 'down (car-safe last-input-event))))
(defvar mpc--faster-toggle-forward nil)
(defvar mpc--faster-acceleration 0.5)
(defun mpc--faster-toggle (speedup step)
- (setq speedup (float speedup))
(if mpc--faster-toggle-timer
(mpc--faster-stop)
(mpc-status-refresh) (mpc-proc-sync)
(setq songtime (string-to-number
(cdr (assq 'time mpc-status))))
(setq songduration (mpc--songduration))
- (setq oldtime (float-time)))
+ (setq oldtime (current-time)))
((and (>= songtime songduration) mpc--faster-toggle-forward)
;; Skip to the beginning of the next song.
(if (not (equal (cdr (assq 'state mpc-status)) "play"))
(lambda ()
(setq songid (cdr (assq 'songid mpc-status)))
(setq songtime (setq songduration (mpc--songduration)))
- (setq oldtime (float-time))
+ (setq oldtime (current-time))
(mpc-proc-cmd (list "seekid" songid songtime)))))))
(t
(setq speedup (+ speedup mpc--faster-acceleration))
(let ((newstep
- (truncate (* speedup (- (float-time) oldtime)))))
+ (truncate
+ (* speedup
+ (float-time (time-since oldtime))))))
(if (<= newstep 1) (setq newstep 1))
- (setq oldtime (+ oldtime (/ newstep speedup)))
+ (setq oldtime (time-add oldtime (/ newstep speedup)))
(if (not mpc--faster-toggle-forward)
(setq newstep (- newstep)))
(setq songtime (min songduration (+ songtime newstep)))
(unless (< len 10)
(setq imap-have-messaged t)
(message "imap read: %dk" len))
- (accept-process-output imap-process
- (truncate imap-read-timeout)
- (truncate (* (- imap-read-timeout
- (truncate imap-read-timeout))
- 1000)))))
+ (accept-process-output imap-process imap-read-timeout)))
;; A process can die _before_ we have processed everything it
;; has to say. Moreover, this can happen in between the call to
;; accept-process-output and the call to process-status in an
(time-less-p nil
(time-add (file-attribute-modification-time
(file-attributes image-name))
- (encode-time 86400))))
+ 86400)))
(newsticker--debug-msg "%s: Getting image for %s skipped"
(format-time-string "%A, %H:%M")
feed-name)
(mapc
(lambda (item)
(when (eq (newsticker--age item) old-age)
- (let ((exp-time (time-add (newsticker--time item)
- (encode-time time))))
+ (let ((exp-time (time-add (newsticker--time item) time)))
(when (time-less-p exp-time nil)
(newsticker--debug-msg
"Item `%s' from %s has expired on %s"
(defun rcirc-handler-ctcp-KEEPALIVE (process _target _sender message)
(with-rcirc-process-buffer process
- (setq header-line-format (format "%f" (- (float-time)
- (string-to-number message))))))
+ (setq header-line-format
+ (format "%f" (float-time
+ (time-since (string-to-number message)))))))
(defvar rcirc-debug-buffer "*rcirc debug*")
(defvar rcirc-debug-flag nil
(< 0 rcirc-reconnect-delay))
(let ((now (current-time)))
(when (or (null rcirc-last-connect-time)
- (< rcirc-reconnect-delay
- (float-time (time-subtract now rcirc-last-connect-time))))
+ (time-less-p rcirc-reconnect-delay
+ (time-subtract now rcirc-last-connect-time)))
(setq rcirc-last-connect-time now)
(rcirc-cmd-reconnect nil))))
(run-hook-with-args 'rcirc-sentinel-functions process sentinel))))
(let* ((nick (nth 1 args))
(idle-secs (string-to-number (nth 2 args)))
(idle-string (format-seconds "%yy %dd %hh %mm %z%ss" idle-secs))
- (signon-time (encode-time (string-to-number (nth 3 args))))
+ (signon-time (string-to-number (nth 3 args)))
(signon-string (format-time-string "%c" signon-time))
(message (format "%s idle for %s, signed on %s"
nick idle-string signon-string)))
(with-current-buffer buffer
(let ((setter (nth 2 args))
(time (current-time-string
- (encode-time
- (string-to-number (cl-cadddr args))))))
+ (string-to-number (cl-cadddr args)))))
(rcirc-print process sender "TOPIC" (cadr args)
(format "%s (%s on %s)" rcirc-topic setter time))))))
(and (consp value)
(or (null remote-file-name-inhibit-cache)
(and (integerp remote-file-name-inhibit-cache)
- (<= (tramp-time-diff (current-time) (car value))
- remote-file-name-inhibit-cache))
+ (time-less-p nil
+ (time-add (car value)
+ remote-file-name-inhibit-cache)))
(and (consp remote-file-name-inhibit-cache)
(time-less-p
remote-file-name-inhibit-cache (car value)))))
(tramp-compat-time-equal-p
(tramp-compat-file-attribute-modification-time fa2)
tramp-time-dont-know)))
- (> 0 (tramp-time-diff
- (tramp-compat-file-attribute-modification-time fa2)
- (tramp-compat-file-attribute-modification-time fa1)))
+ (time-less-p
+ (tramp-compat-file-attribute-modification-time fa2)
+ (tramp-compat-file-attribute-modification-time fa1))
;; If one of them is the dont-know value, then we can
;; still try to run a shell command on the remote host.
;; However, this only works if both files are Tramp
(unless (or (process-live-p p)
(not (tramp-file-name-equal-p
vec (car tramp-current-connection)))
- (> (tramp-time-diff
- (current-time) (cdr tramp-current-connection))
- (or tramp-connection-min-time-diff 0)))
+ (time-less-p
+ (or tramp-connection-min-time-diff 0)
+ (time-since (cdr tramp-current-connection))))
(throw 'suppress 'suppress))
;; If too much time has passed since last command was sent, look
;; try to send a command from time to time, then look again
;; whether the process is really alive.
(condition-case nil
- (when (and (> (tramp-time-diff
- (current-time)
- (tramp-get-connection-property
- p "last-cmd-time" '(0 0 0)))
- 60)
+ (when (and (time-less-p 60
+ (time-since
+ (tramp-get-connection-property
+ p "last-cmd-time" 0)))
(process-live-p p))
(tramp-send-command vec "echo are you awake" t t)
(unless (and (process-live-p p)
;; connection timeout.
(with-current-buffer buf
(goto-char (point-min))
- (when (and (> (tramp-time-diff
- (current-time)
- (tramp-get-connection-property
- p "last-cmd-time" '(0 0 0)))
- 60)
+ (when (and (time-less-p 60
+ (time-since
+ (tramp-get-connection-property
+ p "last-cmd-time" 0)))
(process-live-p p)
(re-search-forward tramp-smb-errors nil t))
(delete-process p)
(let* ((start (current-time))
(val (apply function args)))
(message "%s ran in %g seconds"
- function
- (float-time (time-subtract nil start)))
+ function (float-time (time-since start)))
val))
(defun rng-time-tokenize-buffer ()
(or (widget-get widget :tag) "")
(format-time-string
"%d %B %Y, %T"
- (encode-time
- (string-to-number (widget-get widget :xesam:sourceModified)))))))
+ (string-to-number (widget-get widget :xesam:sourceModified))))))
;; Second line: :value.
(widget-put widget :value (widget-get widget :xesam:url))
((> dt (* 60 maxtime))
;; a very long clocking chunk
(setq issue (format "Clocking interval is very long: %s"
- (org-duration-from-minutes (floor (/ dt 60.))))
+ (org-duration-from-minutes (floor dt 60)))
face (or (plist-get pl :long-face) face)))
((< dt (* 60 mintime))
;; a very short clocking chunk
(setq issue (format "Clocking interval is very short: %s"
- (org-duration-from-minutes (floor (/ dt 60.))))
+ (org-duration-from-minutes (floor dt 60)))
face (or (plist-get pl :short-face) face)))
((and (> tlend 0) (< ts tlend))
;; Two clock entries are overlapping
(throw 'exit t))
;; We have a shorter gap.
;; Now we have to get the minute of the day when these times are
- (let* ((t1dec (decode-time (encode-time t1)))
- (t2dec (decode-time (encode-time t2)))
+ (let* ((t1dec (decode-time t1))
+ (t2dec (decode-time t2))
;; compute the minute on the day
(min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
(min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))
;; Do not use `org-today' here because appt only takes
;; time and without date as argument, so it may pass wrong
;; information otherwise
- (today (org-date-to-gregorian
- (time-to-days (current-time))))
+ (today (org-date-to-gregorian (time-to-days nil)))
(org-agenda-restrict nil)
(files (org-agenda-files 'unrestricted)) entries file
(org-agenda-buffer nil))
(equal current-prefix-arg 1))
;; Prompt for date.
(let ((prompt-time (org-read-date
- nil t nil "Date for tree entry:"
- (current-time))))
+ nil t nil "Date for tree entry:" nil)))
(org-capture-put
:default-time
(cond ((and (or (not (boundp 'org-time-was-given))
The time returned includes the time spent on this task in
previous clocking intervals."
(let ((currently-clocked-time
- (floor (encode-time (time-subtract nil org-clock-start-time) 'integer)
+ (floor (encode-time (time-since org-clock-start-time) 'integer)
60)))
(+ currently-clocked-time (or org-clock-total-time 0))))
(unless (org-is-active-clock clock)
(org-clock-clock-in clock t))))
- ((not (time-less-p resolve-to (current-time)))
+ ((not (time-less-p resolve-to nil))
(error "RESOLVE-TO must refer to a time in the past"))
(t
nil 45)))
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
(default
- (floor (encode-time (time-subtract (current-time) last-valid)
- 'integer)
+ (floor (encode-time (time-since last-valid) 'integer)
60))
(keep
(and (memq ch '(?k ?K))
(and (memq ch '(?g ?G))
(read-number "Got back how many minutes ago? " default)))
(subtractp (memq ch '(?s ?S)))
- (barely-started-p (< (- (float-time last-valid)
- (float-time (cdr clock))) 45))
+ (barely-started-p (time-less-p
+ (time-subtract last-valid (cdr clock))
+ 45))
(start-over (and subtractp barely-started-p)))
(cond
((memq ch '(?j ?J))
(and gotback (= gotback default)))
'now)
(keep
- (time-add last-valid (encode-time (* 60 keep))))
+ (time-add last-valid (* 60 keep)))
(gotback
- (time-subtract (current-time)
- (encode-time (* 60 gotback))))
+ (time-since (* 60 gotback)))
(t
(error "Unexpected, please report this as a bug")))
(and gotback last-valid)
(lambda (clock)
(format
"Dangling clock started %d mins ago"
- (floor (encode-time (time-subtract nil (cdr clock))
+ (floor (encode-time (time-since (cdr clock))
'integer)
60)))))
(or last-valid
org-clock-marker (marker-buffer org-clock-marker))
(let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
(org-clock-user-idle-start
- (time-subtract (current-time)
- (encode-time org-clock-user-idle-seconds)))
+ (time-since org-clock-user-idle-seconds))
(org-clock-resolving-clocks-due-to-idleness t))
(if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
(org-clock-resolve
(lambda (_)
(format "Clocked in & idle for %.1f mins"
(/ (float-time
- (time-subtract (current-time)
- org-clock-user-idle-start))
- 60.0)))
+ (time-since org-clock-user-idle-start))
+ 60)))
org-clock-user-idle-start)))))
(defvar org-clock-current-task nil "Task currently clocked in.")
(y-or-n-p
(format
"You stopped another clock %d mins ago; start this one from then? "
- (/ (- (float-time
- (org-current-time org-clock-rounding-minutes t))
- (float-time leftover))
+ (/ (encode-time
+ (time-subtract
+ (org-current-time org-clock-rounding-minutes t)
+ leftover)
+ 'integer)
60)))
leftover)
start-time
(delete-region (point) (point-at-eol))
(insert "--")
(setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
- (setq s (float-time (time-subtract
- (org-time-string-to-time te)
- (org-time-string-to-time ts)))
+ (setq s (encode-time (time-subtract
+ (org-time-string-to-time te)
+ (org-time-string-to-time ts))
+ 'integer)
h (floor s 3600)
- s (- s (* 3600 h))
- m (floor s 60))
+ m (floor (mod s 3600) 60))
(insert " => " (format "%2d:%02d" h m))
(move-marker org-clock-marker nil)
(move-marker org-clock-hd-marker nil)
;; Possibly remove zero time clocks. However, do not add
;; a note associated to the CLOCK line in this case.
(cond ((and org-clock-out-remove-zero-time-clocks
- (= (+ h m) 0))
+ (= 0 h m))
(setq remove t)
(delete-region (line-beginning-position)
(line-beginning-position 2)))
tend
(>= (float-time org-clock-start-time) tstart)
(<= (float-time org-clock-start-time) tend))
- (let ((time (floor (- (float-time)
- (float-time org-clock-start-time))
+ (let ((time (floor (encode-time
+ (time-since org-clock-start-time)
+ 'integer)
60)))
(setq t1 (+ t1 time))))
(let* ((headline-forced
(setq te (float-time (org-time-string-to-time te)))))
(setq tsb
(if (eq step0 'week)
- (let ((dow (nth 6 (decode-time (encode-time ts)))))
+ (let ((dow (nth 6 (decode-time ts))))
(if (<= dow ws) ts
(- ts (* 86400 (- dow ws)))))
ts))
(while (< tsb te)
(unless (bolp) (insert "\n"))
(let ((start-time (max tsb ts)))
- (cl-incf tsb (let ((dow (nth 6 (decode-time (encode-time tsb)))))
+ (cl-incf tsb (let ((dow (nth 6 (decode-time tsb))))
(if (or (eq step0 'day)
(= dow ws))
step
:tstart (format-time-string (org-time-stamp-format t t)
start-time)
:tend (format-time-string (org-time-stamp-format t t)
- (encode-time (min te tsb))))))))
+ (min te tsb)))))))
(re-search-forward "^[ \t]*#\\+END:")
(when (and stepskip0 (equal step-time 0))
;; Remove the empty table
(eol (line-end-position))
(pom (or (get-text-property bol 'org-hd-marker) (point)))
(key (or key (get-char-property (point) 'org-columns-key)))
- (org-columns--time (float-time (current-time)))
+ (org-columns--time (float-time))
(action
(pcase key
("CLOCKSUM"
(org-columns-goto-top-level)
;; Initialize `org-columns-current-fmt' and
;; `org-columns-current-fmt-compiled'.
- (let ((org-columns--time (float-time (current-time))))
+ (let ((org-columns--time (float-time)))
(org-columns-get-format columns-fmt-string)
(unless org-columns-inhibit-recalculation (org-columns-compute-all))
(save-excursion
(if (markerp org-columns-begin-marker)
(move-marker org-columns-begin-marker (point))
(setq org-columns-begin-marker (point-marker)))
- (let* ((org-columns--time (float-time (current-time)))
+ (let* ((org-columns--time (float-time))
(fmt
(cond
((bound-and-true-p org-agenda-overriding-columns-format))
Raise an error if expected format is unknown."
(pcase (or fmt org-duration-format)
(`h:mm
- (let ((minutes (floor minutes)))
- (format "%d:%02d" (/ minutes 60) (mod minutes 60))))
+ (format "%d:%02d" (/ minutes 60) (mod minutes 60)))
(`h:mm:ss
(let* ((whole-minutes (floor minutes))
- (seconds (floor (* 60 (- minutes whole-minutes)))))
+ (seconds (mod (* 60 minutes) 60)))
(format "%s:%02d"
(org-duration-from-minutes whole-minutes 'h:mm)
seconds)))
(pcase-let* ((`(,unit . ,required?) units)
(modifier (org-duration--modifier unit canonical)))
(cond ((<= modifier minutes)
- (let ((value (if (integerp modifier)
- (/ (floor minutes) modifier)
- (floor (/ minutes modifier)))))
+ (let ((value (floor minutes modifier)))
(cl-decf minutes (* value modifier))
(format " %d%s" value unit)))
(required? (concat " 0" unit))
(defvar org-element-cache-sync-idle-time 0.6
"Length, in seconds, of idle time before syncing cache.")
-(defvar org-element-cache-sync-duration (encode-time 0.04)
+(defvar org-element-cache-sync-duration 0.04
"Maximum duration, as a time value, for a cache synchronization.
If the synchronization is not over after this delay, the process
pauses and resumes after `org-element-cache-sync-break'
seconds.")
-(defvar org-element-cache-sync-break (encode-time 0.3)
+(defvar org-element-cache-sync-break 0.3
"Duration, as a time value, of the pause between synchronizations.
See `org-element-cache-sync-duration' for more information.")
TIME-LIMIT is a time value or nil."
(and time-limit
(or (input-pending-p)
- (time-less-p time-limit (current-time)))))
+ (time-less-p time-limit nil))))
(defsubst org-element--cache-shift-positions (element offset &optional props)
"Shift ELEMENT properties relative to buffer positions by OFFSET.
(and next (aref next 0))
threshold
(and (not threshold)
- (time-add (current-time)
- org-element-cache-sync-duration))
+ (time-add nil org-element-cache-sync-duration))
future-change)
;; Request processed. Merge current and next offsets and
;; transfer ending position.
(deadline (if scheduled-days
(+ scheduled-days (- d-repeat s-repeat))
(org-habit-deadline habit)))
- (m-days (or now-days (time-to-days (current-time)))))
+ (m-days (or now-days (time-to-days nil))))
(cond
((< m-days scheduled)
'(org-habit-clear-face . org-habit-clear-future-face))
"Insert consistency graph for any habitual tasks."
(let ((inhibit-read-only t)
(buffer-invisibility-spec '(org-link))
- (moment (time-subtract (current-time)
- (list 0 (* 3600 org-extend-today-until) 0))))
+ (moment (time-since (* 3600 org-extend-today-until))))
(save-excursion
(goto-char (if line (point-at-bol) (point-min)))
(while (not (eobp))
(let* ((case-fold-search t)
(limited-re (org-get-limited-outline-regexp))
(level (or (org-current-level) 0))
- (time-limit (and delay (time-add (current-time) delay))))
+ (time-limit (and delay (time-add nil delay))))
;; For each line, set `line-prefix' and `wrap-prefix'
;; properties depending on the type of line (headline, inline
;; task, item or other).
;; In asynchronous mode, take a break of
;; `org-indent-agent-resume-delay' every DELAY to avoid
;; blocking any other idle timer or process output.
- ((and delay (time-less-p time-limit (current-time)))
+ ((and delay (time-less-p time-limit nil))
(setq org-indent-agent-resume-timer
(run-with-idle-timer
(time-add (current-idle-time) org-indent-agent-resume-delay)
(sres (if (= org-timecnt 0)
(number-to-string res)
(setq diff (* 3600 res)
- h (floor (/ diff 3600)) diff (mod diff 3600)
- m (floor (/ diff 60)) diff (mod diff 60)
+ h (floor diff 3600) diff (mod diff 3600)
+ m (floor diff 60) diff (mod diff 60)
s diff)
(format "%.0f:%02.0f:%02.0f" h m s))))
(kill-new sres)
(format "Restart timer with offset [%s]: " def)))
(unless (string-match "\\S-" s) (setq s def))
(setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
- (setq org-timer-start-time
- (encode-time
- ;; Pass `current-time' result to `float-time' (instead
- ;; of calling without arguments) so that only
- ;; `current-time' has to be overridden in tests.
- (- (float-time (current-time)) delta))))
+ (setq org-timer-start-time (time-since delta)))
(setq org-timer-pause-time nil)
(org-timer-set-mode-line 'on)
(message "Timer start time set to %s, current value is %s"
(setq org-timer-countdown-timer
(org-timer--run-countdown-timer
new-secs org-timer-countdown-timer-title))
- (setq org-timer-start-time
- (time-add (current-time) (encode-time new-secs))))
+ (setq org-timer-start-time (time-add nil new-secs)))
(setq org-timer-start-time
- ;; Pass `current-time' result to `float-time' (instead
- ;; of calling without arguments) so that only
- ;; `current-time' has to be overridden in tests.
- (encode-time (- (float-time (current-time))
- (- pause-secs start-secs)))))
+ (time-since (- pause-secs start-secs))))
(setq org-timer-pause-time nil)
(org-timer-set-mode-line 'on)
(run-hooks 'org-timer-continue-hook)
(abs (floor (org-timer-seconds))))))
(defun org-timer-seconds ()
- ;; Pass `current-time' result to `float-time' (instead of calling
- ;; without arguments) so that only `current-time' has to be
- ;; overridden in tests.
- (if org-timer-countdown-timer
- (- (float-time org-timer-start-time)
- (float-time (or org-timer-pause-time (current-time))))
- (- (float-time (or org-timer-pause-time (current-time)))
- (float-time org-timer-start-time))))
+ (let ((s (float-time (time-subtract org-timer-pause-time
+ org-timer-start-time))))
+ (if org-timer-countdown-timer (- s) s)))
;;;###autoload
(defun org-timer-change-times-in-region (beg end delta)
(message "No timer set")
(let* ((rtime (decode-time
(time-subtract (timer--time org-timer-countdown-timer)
- (current-time))))
+ nil)))
(rsecs (nth 0 rtime))
(rmins (nth 1 rtime)))
(message "%d minute(s) %d seconds left before next time out"
(org-timer--run-countdown-timer
secs org-timer-countdown-timer-title))
(run-hooks 'org-timer-set-hook)
- (setq org-timer-start-time
- (time-add (current-time) (encode-time secs)))
+ (setq org-timer-start-time (time-add nil secs))
(setq org-timer-pause-time nil)
(org-timer-set-mode-line 'on))))))
(interactive "fFile to load: \nP")
(let* ((age (lambda (file)
(float-time
- (time-subtract (current-time)
- (file-attribute-modification-time
- (or (file-attributes (file-truename file))
- (file-attributes file)))))))
+ (time-since
+ (file-attribute-modification-time
+ (or (file-attributes (file-truename file))
+ (file-attributes file)))))))
(base-name (file-name-sans-extension file))
(exported-file (concat base-name ".el")))
;; tangle if the Org file is newer than the elisp file
(defun org-today ()
"Return today date, considering `org-extend-today-until'."
(time-to-days
- (time-subtract (current-time)
- (list 0 (* 3600 org-extend-today-until) 0))))
+ (time-since (* 3600 org-extend-today-until))))
;;;; Font-Lock stuff, including the activators
(while (re-search-forward org-clock-line-re end t)
(when (org-at-clock-log-p) (throw :clock t))))))
(org-entry-put nil "LAST_REPEAT" (format-time-string
- (org-time-stamp-format t t)
- (current-time))))
+ (org-time-stamp-format t t))))
(when org-log-repeat
(if (or (memq 'org-add-log-note (default-value 'post-command-hook))
(memq 'org-add-log-note post-command-hook))
(let ((nshiftmax 10)
(nshift 0))
(while (or (= nshift 0)
- (not (time-less-p (current-time) time)))
+ (not (time-less-p nil time)))
(when (= (cl-incf nshift) nshiftmax)
(or (y-or-n-p
(format "%d repeater intervals were not \
((stringp s)
(condition-case nil
(float-time (org-time-string-to-time s))
- (error 0.)))
- (t 0.)))
+ (error 0)))
+ (t 0)))
(defun org-time-today ()
"Time in seconds today at 0:00.
((org-at-timestamp-p 'lax) (match-string 0))))
;; Default time is either the timestamp at point or today.
;; When entering a range, only the range start is considered.
- (default-time (if (not ts) (current-time)
- (org-time-string-to-time ts)))
+ (default-time (and ts (org-time-string-to-time ts)))
(default-input (and ts (org-get-compact-tod ts)))
(repeater (and ts
(string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts)
(match-string 0 ts)))
org-time-was-given
org-end-time-was-given
- (time
- (and (if (equal arg '(16)) (current-time)
+ (time (if (equal arg '(16)) (current-time)
;; Preserve `this-command' and `last-command'.
(let ((this-command this-command)
(last-command last-command))
(org-read-date
arg 'totime nil nil default-time default-input
- inactive))))))
+ inactive)))))
(cond
((and ts
(memq last-command '(org-time-stamp org-time-stamp-inactive))
(when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
(setq ans "+0"))
- (when (setq delta (org-read-date-get-relative ans (current-time) org-def))
+ (when (setq delta (org-read-date-get-relative ans nil org-def))
(setq ans (replace-match "" t t ans)
deltan (car delta)
deltaw (nth 1 delta)
; (when (and org-read-date-prefer-future
; (not iso-year)
; (< (calendar-absolute-from-gregorian iso-date)
- ; (time-to-days (current-time))))
+ ; (time-to-days nil)))
; (setq year (1+ year)
; iso-date (calendar-gregorian-from-absolute
; (calendar-iso-to-absolute
If SECONDS is non-nil, return the difference in seconds."
(let ((fdiff (if seconds #'float-time #'time-to-days)))
(- (funcall fdiff (org-time-string-to-time timestamp-string))
- (funcall fdiff (current-time)))))
+ (funcall fdiff nil))))
(defun org-deadline-close-p (timestamp-string &optional ndays)
"Is the time in TIMESTAMP-STRING close to the current date?"
(match-end (match-end 0))
(time1 (org-time-string-to-time ts1))
(time2 (org-time-string-to-time ts2))
- (t1 (float-time time1))
- (t2 (float-time time2))
- (diff (abs (- t2 t1)))
- (negative (< (- t2 t1) 0))
+ (diff (abs (float-time (time-subtract time2 time1))))
+ (negative (time-less-p time2 time1))
;; (ys (floor (* 365 24 60 60)))
(ds (* 24 60 60))
(hs (* 60 60))
(fh "%02d:%02d")
y d h m align)
(if havetime
- (setq ; y (floor (/ diff ys)) diff (mod diff ys)
+ (setq ; y (floor diff ys) diff (mod diff ys)
y 0
- d (floor (/ diff ds)) diff (mod diff ds)
- h (floor (/ diff hs)) diff (mod diff hs)
- m (floor (/ diff 60)))
- (setq ; y (floor (/ diff ys)) diff (mod diff ys)
+ d (floor diff ds) diff (mod diff ds)
+ h (floor diff hs) diff (mod diff hs)
+ m (floor diff 60))
+ (setq ; y (floor diff ys) diff (mod diff ys)
y 0
- d (floor (+ (/ diff ds) 0.5))
+ d (round diff ds)
h 0 m 0))
(if (not to-buffer)
(message "%s" (org-make-tdiff-string y d h m))
YEAR is expanded into one of the 30 next years, if possible, or
into a past one. Any year larger than 99 is returned unchanged."
(if (>= year 100) year
- (let* ((current (string-to-number (format-time-string "%Y" (current-time))))
+ (let* ((current (string-to-number (format-time-string "%Y")))
(century (/ current 100))
(offset (- year (% current 100))))
(cond ((> offset 30) (+ (* (1- century) 100) year))
diff)
(when (or (org-at-timestamp-p 'lax)
(org-match-line (concat ".*" org-ts-regexp)))
- (let ((d1 (time-to-days (current-time)))
+ (let ((d1 (time-to-days nil))
(d2 (time-to-days (org-time-string-to-time (match-string 1)))))
(setq diff (- d2 d1))))
(calendar)
(expand-file-name (or (file-symlink-p file) file)
(file-name-directory file)))))
(if (not attr) (error "No such file: \"%s\"" file)
- (floor (float-time (file-attribute-modification-time attr))))))
+ (encode-time (file-attribute-modification-time attr) 'integer))))
(provide 'ox-publish)
(let ((val (cond ((equal (car key) "DATE")
(or (cdr key)
(with-temp-buffer
- (org-insert-time-stamp (current-time)))))
+ (org-insert-time-stamp nil))))
((equal (car key) "TITLE")
(or (let ((visited-file
(buffer-file-name (buffer-base-buffer))))
user is in hurry. When the time since last scroll is larger than
`pixel-dead-time', we are ready for another smooth scroll, and this
function returns nil."
- (let* ((current-time (float-time))
- (scroll-in-rush-p (< (- current-time pixel-last-scroll-time)
- pixel-dead-time)))
- (setq pixel-last-scroll-time current-time)
+ (let* ((now (current-time))
+ (scroll-in-rush-p (time-less-p
+ (time-subtract now pixel-last-scroll-time)
+ pixel-dead-time)))
+ (setq pixel-last-scroll-time (float-time now))
scroll-in-rush-p))
;;;###autoload
(cl-loop for elapsed = (- (float-time) start-time)
while (< elapsed hanoi-move-period)
with tick-period = (/ (float hanoi-move-period) total-ticks)
- for tick = (ceiling (/ elapsed tick-period)) do
+ for tick = (ceiling elapsed tick-period) do
(hanoi-ring-to-pos ring (funcall tick-to-pos tick))
(hanoi-sit-for (- (* tick tick-period) elapsed)))
(cl-loop for tick from 1 to total-ticks by 2 do
(defun proced-format-time (time)
"Format time interval TIME."
- (let* ((ftime (float-time time))
+ (let* ((ftime (encode-time time 'integer))
(days (truncate ftime 86400))
(ftime (mod ftime 86400))
(hours (truncate ftime 3600))
ARGS are the same as for `message'."
(when cpp-message-min-time-interval
(let ((time (current-time)))
- (when (>= (float-time (time-subtract time cpp-progress-time))
- cpp-message-min-time-interval)
+ (unless (time-less-p cpp-message-min-time-interval
+ (time-subtract time cpp-progress-time))
(setq cpp-progress-time time)
(apply 'message args)))))
(flymake-log :debug "backend %s reported %d diagnostics in %.2f second(s)"
backend
(length new-diags)
- (- (float-time) flymake-check-start-time)))
+ (float-time
+ (time-since flymake-check-start-time))))
(when (and (get-buffer (flymake--diagnostics-buffer-name))
(get-buffer-window (flymake--diagnostics-buffer-name))
(null (cl-set-difference (flymake-running-backends)
(with-current-buffer (process-buffer process)
(cl-loop with start-pos = (or start
(marker-position (process-mark process)))
- with end-time = (+ (float-time) timeout)
- for time-left = (- end-time (float-time))
+ with end-time = (time-add nil timeout)
+ for time-left = (float-time (time-subtract end-time nil))
do (goto-char (point-max))
if (looking-back regexp start-pos) return t
while (> time-left 0)
"Update progress information."
(when (and vhdl-progress-info (not noninteractive)
(time-less-p vhdl-progress-interval
- (time-subtract nil (aref vhdl-progress-info 2))))
+ (time-since (aref vhdl-progress-info 2))))
(let ((delta (- (aref vhdl-progress-info 1)
(aref vhdl-progress-info 0))))
(message "%s... (%2d%%)" string
(downcase-word -1)))
(when (and count vhdl-progress-interval (not noninteractive)
(time-less-p vhdl-progress-interval
- (time-subtract nil last-update)))
+ (time-since last-update)))
(message "Fixing case... (%2d%s)"
(+ (* count 20) (/ (* 20 (- (point) beg)) (- end beg)))
"%")
(defmacro ses--time-check (format &rest args)
"If `ses-start-time' is more than a second ago, call `message' with FORMAT
and ARGS and reset `ses-start-time' to the current time."
- `(when (> (- (float-time) ses-start-time) 1.0)
+ `(when (time-less-p 1 (time-since ses-start-time))
(message ,format ,@args)
(setq ses-start-time (float-time))))
(enough-time-passed
;; See if enough time has passed since the last update.
(or (not update-time)
- (when (>= (float-time) update-time)
+ (when (time-less-p update-time nil)
;; Calculate time for the next update
(aset parameters 0 (+ update-time (aref parameters 5)))))))
(cond ((and min-value max-value)
By not redisplaying right away for xterm queries, we can avoid
unsightly flashing during initialization. Give up and redisplay
anyway if we've been waiting a little while."
- (let ((start-time (float-time)))
+ (let ((start-time (current-time)))
(or (let ((inhibit-redisplay t))
(read-event nil nil xterm-query-redisplay-timeout))
(read-event nil nil
(and xterm-query-timeout
- (max 0 (+ start-time xterm-query-timeout
- (- (float-time)))))))))
+ (max 0 (float-time
+ (time-subtract
+ xterm-query-timeout
+ (time-since start-time)))))))))
(defun xterm--query (query handlers &optional no-async)
"Send QUERY string to the terminal and watch for a response.
((and (stringp mail-spool-file)
(or (null display-time-server-down-time)
;; If have been down for 20 min, try again.
- (< 1200 (- (float-time now)
- display-time-server-down-time))))
- (let ((start-time (float-time)))
+ (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)
;; Record whether mail file is accessible.
(setq display-time-server-down-time
- (let ((end-time (float-time)))
- (and (< 20 (- end-time start-time))
- end-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))))
(interactive)
(let ((str
(format-seconds (or format "%Y, %D, %H, %M, %z%S")
- (float-time
- (time-subtract nil before-init-time)))))
+ (encode-time
+ (time-since before-init-time)
+ 'integer))))
(if (called-interactively-p 'interactive)
(message "%s" str)
str)))
(defun tooltip-delay ()
"Return the delay in seconds for the next tooltip."
(if (and tooltip-hide-time
- (< (- (float-time) tooltip-hide-time) tooltip-recent-seconds))
+ (time-less-p (time-since tooltip-hide-time)
+ tooltip-recent-seconds))
tooltip-short-delay
tooltip-delay))
))))))
(defun timep (time)
- "If TIME is in the format returned by `current-time' then
-return TIME, else return nil."
+ "If TIME is a Lisp time value then return TIME, else return nil."
(condition-case nil
(and (float-time time) time)
(error nil)))
(defun type-break-get-previous-time ()
"Get previous break time from `type-break-file-name'.
-Returns nil if the file is missing or if the time breaks with the
-`current-time' format."
+Return nil if the file is missing or if the time is not a Lisp time value."
(let ((file (type-break-choose-file)))
(if file
(timep ;; returns expected format, else nil
((and (car type-break-keystroke-threshold)
(< type-break-keystroke-count (car type-break-keystroke-threshold))))
((> type-break-time-warning-count 0)
- (let ((timeleft (type-break-time-difference (current-time)
+ (let ((timeleft (type-break-time-difference nil
type-break-time-next-break)))
(setq type-break-warning-countdown-string (number-to-string timeleft))
(cond
(current-time-string type-break-time-next-break)
(type-break-format-time
(type-break-time-difference
- (current-time)
- type-break-time-next-break)))
+ nil
+ type-break-time-next-break)))
"none scheduled")
(or (car type-break-keystroke-threshold) "none")
(or (cdr type-break-keystroke-threshold) "none")
(erase-buffer)
(setq elapsed (type-break-time-difference
type-break-time-last-break
- (current-time)))
+ nil))
(let ((good-interval (or type-break-good-rest-interval
type-break-good-break-interval)))
(cond
(time-less-p
(time-add
cache-time
- (encode-time (or expire-time url-cache-expire-time)))
+ (or expire-time url-cache-expire-time))
nil)))))
(defun url-cache-prune-cache (&optional directory)
((time-less-p
(time-add
(file-attribute-modification-time (file-attributes file))
- (encode-time url-cache-expire-time))
+ url-cache-expire-time)
now)
(delete-file file)
(setq deleted-files (1+ deleted-files))))))
;; away, make it expire a year from now
(expires (format-time-string
"%d %b %Y %T [GMT]"
- (encode-time
- (let ((s (string-to-number (nth 4 fields))))
- (if (and (= s 0) long-session)
- (encode-time (+ (* 365 24 60 60) (float-time)))
- s)))))
+ (let ((s (string-to-number (nth 4 fields))))
+ (if (and (zerop s) long-session)
+ (time-add nil (* 365 24 60 60))
+ s))))
(key (nth 5 fields))
(val (nth 6 fields)))
(cl-incf n)
(dolist (job url-queue)
;; Kill jobs that have lasted longer than the timeout.
(when (and (url-queue-start-time job)
- (> (- (float-time) (url-queue-start-time job))
- url-queue-timeout))
+ (time-less-p url-queue-timeout
+ (time-since (url-queue-start-time job))))
(push job dead-jobs)))
(dolist (job dead-jobs)
(url-queue-kill-job job)
;; process output.
(while (and (not retrieval-done)
(or (not timeout)
- (< (float-time (time-subtract nil start-time))
- timeout)))
+ (time-less-p (time-since start-time) timeout)))
(url-debug 'retrieval
"Spinning in url-retrieve-synchronously: %S (%S)"
retrieval-done asynch-buffer)
"Create a stash with the current tree state."
(interactive)
(vc-git--call nil "stash" "save"
- (let ((ct (current-time)))
- (concat
- (format-time-string "Snapshot on %Y-%m-%d" ct)
- (format-time-string " at %H:%M" ct))))
+ (format-time-string "Snapshot on %Y-%m-%d at %H:%M"))
(vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" "stash@{0}")
(vc-resynch-buffer (vc-git-root default-directory) t t))
;; ;; Terminates man processing
;; "Report formatting time."
;; (message "Man formatting done in %s seconds"
-;; (float-time (time-subtract nil WoMan-Man-start-time))))
+;; (float-time (time-since WoMan-Man-start-time))))
\f
;;; Buffer handling:
(y (nth 2 click))
;; Emulate timestamp information. This is accurate enough
;; for default value of mouse-1-click-follows-link (450msec).
- (timestamp (truncate
- (* 1000
- (- (float-time)
- (or xt-mouse-epoch
- (setq xt-mouse-epoch (float-time)))))))
+ (timestamp (if (not xt-mouse-epoch)
+ (progn (setq xt-mouse-epoch (float-time)) 0)
+ (car (encode-time (time-since xt-mouse-epoch)
+ 1000))))
(w (window-at x y))
(ltrb (window-edges w))
(left (nth 0 ltrb))