summaryrefslogtreecommitdiff
path: root/lisp/erc/erc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc/erc.el')
-rw-r--r--lisp/erc/erc.el41
1 files changed, 17 insertions, 24 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 697e26b7944..101a5a05bf6 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2565,8 +2565,8 @@ consumption for long-lived IRC or Emacs sessions."
(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))
@@ -2631,9 +2631,8 @@ server within `erc-lurker-threshold-time'. See also
(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")
@@ -3412,7 +3411,7 @@ Otherwise leave the channel indicated by LINE."
(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)))
@@ -4640,7 +4639,7 @@ See also `erc-display-message'."
(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)))
@@ -4729,8 +4728,7 @@ See also `erc-display-message'."
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
@@ -4788,10 +4786,7 @@ If non-nil, return from being away."
(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)))
@@ -5383,10 +5378,10 @@ submitted line to be intentional."
(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))
@@ -6036,22 +6031,20 @@ non-nil value is found.
;; 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."