summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-11 12:02:34 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-11 12:02:34 +0100
commita3c366eb98f029315b252212fb8764714249b092 (patch)
tree5b90c6517e3c73c019cbf393a6799199800a5020
parentc93a17dd8ade3a3feb13d89b663006d04f4f2c5a (diff)
downloadorg-mode-a3c366eb98f029315b252212fb8764714249b092.tar.gz
org-colview: Fix time sum when mixing duration and H:MM:SS time
* lisp/org-colview.el (org-columns--time-to-seconds): Recognize a duration even when it contains a H:MM:SS part. * testing/lisp/test-org-colview.el (test-org-colview/columns-summary): Add test. Reported-by: Björn Döring <bjoern@doering.io> <http://permalink.gmane.org/gmane.emacs.orgmode/110144>
-rw-r--r--lisp/org-colview.el6
-rw-r--r--testing/lisp/test-org-colview.el22
2 files changed, 24 insertions, 4 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index d33f505..5223902 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1068,12 +1068,12 @@ This function updates `org-columns-current-fmt-compiled'."
A time is expressed as HH:MM, HH:MM:SS, or with units defined in
`org-effort-durations'. Plain numbers are considered as hours."
(cond
- ((string-match "\\([0-9]+\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?" s)
+ ((string-match-p org-columns--duration-re s)
+ (* 60 (org-duration-string-to-minutes s)))
+ ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?\\'" s)
(+ (* 3600 (string-to-number (match-string 1 s)))
(* 60 (string-to-number (match-string 2 s)))
(if (match-end 3) (string-to-number (match-string 3 s)) 0)))
- ((string-match-p org-columns--duration-re s)
- (* 60 (org-duration-string-to-minutes s)))
(t (* 3600 (string-to-number s)))))
(defun org-columns--age-to-seconds (s)
diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colview.el
index f81dfa1..8b312ab 100644
--- a/testing/lisp/test-org-colview.el
+++ b/testing/lisp/test-org-colview.el
@@ -471,7 +471,8 @@
(let ((org-columns-default-format "%A{@mean}")) (org-columns))
(get-char-property (point) 'org-columns-value-modified)))))
;; If a time value is expressed as a duration, return a duration.
- ;; If any of them follows H:MM:SS pattern, use it too.
+ ;; If any of them follows H:MM:SS pattern, use it too. Also handle
+ ;; combinations of duration and H:MM:SS patterns.
(should
(equal
"1d 4:20"
@@ -506,6 +507,25 @@
:END:"
(let ((org-columns-default-format "%A{:}")) (org-columns))
(get-char-property (point) 'org-columns-value-modified))))
+ (should
+ (equal
+ "1d 4:20"
+ (org-test-with-temp-text
+ "* H
+** S1
+:PROPERTIES:
+:A: 3d 3h
+:END:
+** S1
+:PROPERTIES:
+:A: 0d 1:20
+:END:"
+ (let ((org-columns-default-format "%A{:}")
+ (org-time-clocksum-use-fractional nil)
+ (org-time-clocksum-format
+ '(:days "%dd " :hours "%d" :minutes ":%02d")))
+ (org-columns))
+ (get-char-property (point) 'org-columns-value-modified))))
;; @min, @max and @mean also accept regular duration in
;; a "?d ?h ?m ?s" format.
(should