[gnus git] branch master updated: m0-11-11-g4bc4852 =1= time-date.el (seconds-to-string): New function to pretty print time delay in seconds
Katsumi Yamaoka <[email protected]> Tue, 13 May 2014 00:09:24 +0200
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 4bc48529523159c55dcd62d5a6be60521540b371 (commit)
from dfe57dcf4ac68c07f15c5ed266e831dffabe7df7 (commit)
- Log -----------------------------------------------------------------
commit 4bc48529523159c55dcd62d5a6be60521540b371
Author: Sam Steingold <[email protected]>
Date: Mon May 12 22:09:13 2014 +0000
time-date.el (seconds-to-string): New function to pretty print time delay in seconds
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f4c45b6..05be211 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-12 Sam Steingold <[email protected]>
+
+ * time-date.el (seconds-to-string): New function to pretty print time
+ delay in seconds.
+
2014-05-09 Katsumi Yamaoka <[email protected]>
* gnus-art.el (gnus-mm-display-part): Don't put article out of sight
diff --git a/lisp/time-date.el b/lisp/time-date.el
index 3d62c5d..eb534b6 100644
--- a/lisp/time-date.el
+++ b/lisp/time-date.el
@@ -388,6 +388,23 @@ This function does not work for SECONDS greater than `most-positive-fixnum'."
t t string))))))
(replace-regexp-in-string "%%" "%" string))
+(defvar seconds-to-string
+ (list (list 1 "ms" 0.001)
+ (list 100 "s" 1)
+ (list (* 60 100) "m" 60.0)
+ (list (* 3600 30) "h" 3600.0)
+ (list (* 3600 24 400) "d" (* 3600.0 24.0))
+ (list nil "y" (* 365.25 24 3600)))
+ "Formatting used by the function `seconds-to-string'.")
+;;;###autoload
+(defun seconds-to-string (delay)
+ "Convert the time interval in seconds to a short string."
+ (cond ((> 0 delay) (concat "-" (seconds-to-string (- delay))))
+ ((= 0 delay) "0s")
+ (t (let ((sts seconds-to-string) here)
+ (while (and (car (setq here (pop sts)))
+ (<= (car here) delay)))
+ (concat (format "%.2f" (/ delay (third here))) (second here))))))
(provide 'time-date)
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 5 +++++
lisp/time-date.el | 17 +++++++++++++++++
2 files changed, 22 insertions(+)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project