From 127d3d117e9a299826fccbe185be71535fdc8b41 Mon Sep 17 00:00:00 2001 From: ueno Date: Sun, 27 Feb 2005 01:52:22 +0000 Subject: [PATCH] * riece-300.el (riece-handle-317-message): Format idle seconds in human readable form. --- lisp/ChangeLog | 3 +++ lisp/riece-300.el | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) 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) -- 1.7.10.4