Location: steve@xxxxxxxxxxxxxx http://arch.eicq.org/2005/
Revision: xwem--steve--2.1--patch-2
Archive: steve@xxxxxxxxxxxxxx
Creator: Steve Youngs <steve@xxxxxxxx>
Date: Sun Jan 23 18:57:12 EST 2005
Standard-date: 2005-01-23 08:57:12 GMT
Modified-files: lisp/xwem-clients.el
New-patches: steve@xxxxxxxxxxxxxx/xwem--steve--2.1--patch-2
Summary: Fix client uptimes
Keywords: bugfix
This re-fixes a bug in calculating client uptimes that meant a client's
uptime could not exceed 65535 seconds.
* lisp/xwem-clients.el (xwem-cl-get-uptime-1): New helper function for
calculating client uptimes.
(xwem-cl-get-uptime): Use it.
Also use a nicer output format.
Don't autoload `subtract-time' from time-date.el, it is not needed
anymore. And don't define our own version of it.
* added files
{arch}/xwem/xwem--steve/xwem--steve--2.1/steve@xxxxxxxxxxxxxx/patch-log/patch-2
* modified files
--- orig/lisp/xwem-clients.el
+++ mod/lisp/xwem-clients.el
@@ -73,7 +73,6 @@
(eval-when-compile
;; Shutup compiler
- (autoload 'subtract-time "time-date")
(defvar xwem-frame-ev-mask)
)
@@ -1461,12 +1460,12 @@
(let ((gmt (xwem-cl-xgeom cl)))
(cons (X-Geom-width gmt) (X-Geom-height gmt))))
-(unless (fboundp 'subtract-time)
- (defun subtract-time (t1 t2)
- "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 xwem-cl-get-uptime-1 (cl)
+ (let ((ctime (current-time))
+ (stime (xwem-cl-start-time cl)))
+ (list (- (nth 0 ctime) (nth 0 stime))
+ (- (nth 1 ctime) (nth 1 stime))
+ (- (nth 2 ctime) (nth 2 stime)))))
;;;###xwem-autoload
(defun xwem-cl-get-uptime (cl &optional format)
@@ -1477,25 +1476,15 @@
%m is replaced by the minutes
%s is replaced by the seconds
%A is replaced by autogenerated format."
- (let ((upt (nth 1 (subtract-time (current-time) (xwem-cl-start-time cl))))
- (fmt (or format "%A"))
- (days 0)
- (hours 0)
- (minutes 0)
- (seconds 0)
- (rup ""))
+ (let* ((upt (xwem-cl-get-uptime-1 cl))
+ (upt (+ (* (nth 0 upt) 65536) (mod (nth 1 upt) 65536)))
+ (days (/ upt 86400))
+ (hours (/ (mod upt 86400) 3600))
+ (minutes (/ (mod upt 3600) 60))
+ (seconds (mod upt 60))
+ (fmt (or format "%A"))
+ (rup ""))
- (when (> upt (* 60 60 24))
- (setq days (/ upt (* 60 60 24))))
-
- (when (> upt (* 60 60))
- (setq hours (% (/ upt (* 60 60)) 24)))
-
- (when (> upt 60)
- (setq minutes (% (/ upt 60) 60)))
-
- (setq seconds (% upt 60))
-
(let ((flst (string-to-list fmt))
chr)
(while flst
@@ -1513,12 +1502,12 @@
(setq rup (concat rup (format "%d" seconds))))
((= chr ?A)
(setq rup (concat
- (cond ((> days 0) (format "%dd %dh" days
hours))
- ((> hours 0) (format "%dh %dm" hours
minutes))
+ (cond ((> days 0) (format "%dd %dh %dm %ds"
days hours minutes seconds))
+ ((> hours 0) (format "%dh %dm %ds" hours
minutes seconds))
((> minutes 0) (format "%dm %ds" minutes
seconds))
((> seconds 0) (format "%d seconds"
seconds))
(t "")))))
- (t (error 'xwem-error "Invalid format"))))
+ (t (error "Invalid format"))))
(t (setq rup (concat rup (char-to-string chr)))))
(setq flst (cdr flst))))
|