(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?"