From: ueno Date: Tue, 2 Oct 2001 05:01:08 +0000 (+0000) Subject: * liece-commands.el (liece-command-kill): Use `liece-time-elapsed' X-Git-Tag: liece-1_4_7~29 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=ec5c4ba9ba99ff17935d6bc24c85dba5daaeba35;p=elisp%2Fliece.git * liece-commands.el (liece-command-kill): Use `liece-time-elapsed' instead of `liece-time-add'. * liece-misc.el (liece-time-difference): Define as function. (liece-time-elapsed): Rename from `liece-time-add'. (liece-generate-hex-timestamp): Define as function. --- diff --git a/lisp/liece-commands.el b/lisp/liece-commands.el index 755e028..5062929 100644 --- a/lisp/liece-commands.el +++ b/lisp/liece-commands.el @@ -339,8 +339,8 @@ If SILENT is non-nil, don't notify current status." (car ignore)))) ;; did not find, add to ignored ones (let ((expire-time (if (> timeout 0) - (liece-time-add (current-time) - (* timeout 60))))) + (liece-time-elapsed (current-time) + (* timeout 60))))) (and silent (> timeout 0) (setcar (cdr (cdr expire-time)) -1)) (setq liece-kill-nickname diff --git a/lisp/liece-misc.el b/lisp/liece-misc.el index 4820e9a..6018850 100644 --- a/lisp/liece-misc.el +++ b/lisp/liece-misc.el @@ -431,30 +431,32 @@ (setq who (cdr who))))))) found)) -(defmacro liece-time-difference (t0 t1) - "Difference in seconds between T0 and T1. -Both T0 and T1 are in the encoded time format." - `(abs (+ (* (- (car ,t1) (car ,t0)) 65536) - (- (cadr ,t1)) (cadr ,t0)))) - -(defmacro liece-time-add (t0 t1) - "Add T0 seconds to time T1. -t0 is in `three integer lists'-format returned by `current-time' function." - `(list (+ (car ,t0) (/ (+ (cadr ,t0) ,t1) 65536)) - (% (+ (cadr ,t0) ,t1) 65536) - 0)) - +;;; stolen (and renamed) from time-date.el. +(defun liece-time-difference (t0 t1) + "Subtract two internal times." + (let ((borrow (< (cadr t1) (cadr t2)))) + (list (- (car t1) (car t2) (if borrow 1 0)) + (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2))))) + +(defun liece-time-elapsed (time seconds) + "Add SECONDS to TIME." + (list (+ (car time) (/ (+ (cadr time) seconds) 65536)) + (% (+ (cadr time) seconds) 65536) + (nth 2 time))) + +;;; stolen (and renamed) from time-date.el. (defun liece-seconds-to-time (seconds) "Convert SECONDS (a floating point number) to an Emacs time structure." (list (floor seconds 65536) (floor (mod seconds 65536)) (floor (* (- seconds (ffloor seconds)) 1000000)))) -(defmacro liece-generate-hex-timestamp (&optional time) +(defun liece-generate-hex-timestamp (&optional time) "Generate timestamp string as hexadecimal. If optional argument TIME is nil, calculate timestamp using current time." - `(let ((time (or ,time (current-time)))) - (format "%04x%04x" (car time) (cadr time)))) + (or time + (setq time (current-time))) + (format "%04x%04x" (car time) (cadr time))) (defmacro liece-hex-timestamp-valid (timestamp limit) "Is TIMESTAMP valid within LIMIT?"