Преглед на файлове

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>
Nicolas Goaziou преди 8 години
родител
ревизия
a3c366eb98
променени са 2 файла, в които са добавени 24 реда и са изтрити 4 реда
  1. 3 3
      lisp/org-colview.el
  2. 21 1
      testing/lisp/test-org-colview.el

+ 3 - 3
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)

+ 21 - 1
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