0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:00:49 +00:00

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>
This commit is contained in:
Nicolas Goaziou 2016-11-11 12:02:34 +01:00
parent c93a17dd8a
commit a3c366eb98
2 changed files with 24 additions and 4 deletions

View file

@ -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)

View file

@ -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