From: Daiki Ueno Date: Sun, 27 Feb 2005 01:52:22 +0000 (+0000) Subject: * riece-300.el (riece-handle-317-message): Format idle seconds in X-Git-Url: http://cgit.sxemacs.org/?a=commitdiff_plain;h=78ac843e1969cc20beb6ad959d207e5ec7cea499;p=riece * riece-300.el (riece-handle-317-message): Format idle seconds in human readable form. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 10abc6c..fdbb7ff 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2005-02-27 Daiki Ueno + * riece-300.el (riece-handle-317-message): Format idle seconds in + human readable form. + * riece-ctcp.el (riece-handle-ctcp-action-request): Prepend target. (riece-command-ctcp-action): Ditto. diff --git a/lisp/riece-300.el b/lisp/riece-300.el index 0f3d717..52f7eba 100644 --- a/lisp/riece-300.el +++ b/lisp/riece-300.el @@ -176,17 +176,29 @@ (if (string-match (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) ") string) - (let ((user (match-string 1 string)) - (idle (match-string 2 string))) + (let* ((user (match-string 1 string)) + (seconds (string-to-number (match-string 2 string))) + (units (list (cons (/ seconds 60 60 24) "days") + (cons (mod (/ seconds 60 60) 24) "hours") + (cons (mod (/ seconds 60) 60) "minutes") + (cons (mod seconds 60) "seconds")))) (riece-insert-info (list riece-dialogue-buffer riece-others-buffer) (concat (riece-concat-server-name - (format "%s is %s seconds idle" + (format "%s is %s idle" (riece-format-identity (riece-make-identity user riece-server-name) t) - idle)) + (mapconcat #'identity + (delq nil + (mapcar + (lambda (unit) + (if (/= (car unit) 0) + (format "%d %s" + (car unit) (cdr unit)))) + units)) + ", "))) "\n"))))) (defun riece-handle-319-message (prefix number name string)