From: 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-Tag: riece-1_0_8~23 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=127d3d117e9a299826fccbe185be71535fdc8b41;p=elisp%2Friece.git * 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)