emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] summarize timestamps in column view


From: Pedro Silva
Subject: [O] [PATCH] summarize timestamps in column view
Date: Sun, 9 Jun 2013 01:01:11 +0100

* org-colview.el (org-columns-compile-map):
(org-columns-number-to-string):
(org-columns-string-to-number): Handle timestamp summaries.

* org.texi (Column attributes): Document timestamp summaries.

TINYCHANGE
---
 contrib/lisp/org-colview-xemacs.el | 11 ++++++++++-
 doc/org.texi                       |  3 +++
 lisp/org-colview.el                | 11 ++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/contrib/lisp/org-colview-xemacs.el 
b/contrib/lisp/org-colview-xemacs.el
index 63c0238..c2cff84 100644
--- a/contrib/lisp/org-colview-xemacs.el
+++ b/contrib/lisp/org-colview-xemacs.el
@@ -901,7 +901,12 @@ around it."
     ("@mean" mean_age
      (lambda (&rest x) (/ (apply '+ x) (float (length x))))
      (lambda (x) (- org-columns-time x)))
-    ("est+" estimate org-estimate-combine))
+    ("est+" estimate org-estimate-combine)
+    ("<min" timestamp min org-time-string-to-seconds)
+    ("<max" timestamp min org-time-string-to-seconds)
+    ("<mean" timestamp
+     (lambda (&rest x) (/ (apply '+ x) (float (length x))))
+     org-time-string-to-seconds))
   "Operator <-> format,function,calc  map.
 Used to compile/uncompile columns format and completing read in
 interactive function `org-columns-new'.
@@ -1190,6 +1195,9 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-number-to-string (n fmt &optional printf)
   "Convert a computed column number to a string value, according to FMT."
   (cond
+   ((memq fmt '(timestamp))
+    (format-time-string
+     (or printf (car org-time-stamp-formats)) (seconds-to-time n)))
    ((memq fmt '(estimate)) (org-estimate-print n printf))
    ((not (numberp n)) "")
    ((memq fmt '(add_times max_times min_times mean_times))
@@ -1218,6 +1226,7 @@ Don't set this, this is meant for dynamic scoping.")
   "Convert a column value to a number that can be used for column computing."
   (if s
       (cond
+       ((memq fmt '(timestamp)) s)
        ((memq fmt '(min_age max_age mean_age))
        (cond ((string= s "") org-columns-time)
              ((string-match
diff --git a/doc/org.texi b/doc/org.texi
index 6d5eca0..8b1c49d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5497,6 +5497,9 @@ optional.  The individual parts have the following 
meaning:
                 @{@@address@hidden    @r{Minimum age (in 
days/hours/mins/seconds).}
                 @{@@address@hidden    @r{Maximum age (in 
days/hours/mins/seconds).}
                 @{@@address@hidden   @r{Arithmetic mean of ages (in 
days/hours/mins/seconds).}
+                @{<address@hidden    @r{Minimum timestamp.}
+                @{<address@hidden    @r{Maximum timestamp.}
+                @{<address@hidden   @r{Arithmetic mean of timestamps.}
                 @address@hidden    @r{Add low-high estimates.}
 @end example
 
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index a98deec..f52cb25 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -761,7 +761,12 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column 
format."
     ("@mean" mean_age
      (lambda (&rest x) (/ (apply '+ x) (float (length x))))
      (lambda (x) (- org-columns-time x)))
-    ("est+" estimate org-estimate-combine))
+    ("est+" estimate org-estimate-combine)
+    ("<min" timestamp min org-time-string-to-seconds)
+    ("<max" timestamp min org-time-string-to-seconds)
+    ("<mean" timestamp
+     (lambda (&rest x) (/ (apply '+ x) (float (length x))))
+     org-time-string-to-seconds))
   "Operator <-> format,function,calc  map.
 Used to compile/uncompile columns format and completing read in
 interactive function `org-columns-new'.
@@ -1055,6 +1060,9 @@ Don't set this, this is meant for dynamic scoping.")
 (defun org-columns-number-to-string (n fmt &optional printf)
   "Convert a computed column number to a string value, according to FMT."
   (cond
+   ((memq fmt '(timestamp))
+    (format-time-string
+     (or printf (car org-time-stamp-formats)) (seconds-to-time n)))
    ((memq fmt '(estimate)) (org-estimate-print n printf))
    ((not (numberp n)) "")
    ((memq fmt '(add_times max_times min_times mean_times))
@@ -1083,6 +1091,7 @@ Don't set this, this is meant for dynamic scoping.")
   "Convert a column value to a number that can be used for column computing."
   (if s
       (cond
+       ((memq fmt '(timestamp)) s)
        ((memq fmt '(min_age max_age mean_age))
         (cond ((string= s "") org-columns-time)
               ((string-match
-- 
1.8.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]