summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-05-01 17:47:13 +0200
committerBastien Guerry <bzg@altern.org>2012-05-01 17:47:13 +0200
commit805891523c466643f2efa9c2d5561fdfa8862e7c (patch)
treed778dbef5e12aafa53c627b2578cb1d6adb91f0a
parent4d65272e03a70e20a3ba53624c8e1b240137fd59 (diff)
downloadorg-mode-805891523c466643f2efa9c2d5561fdfa8862e7c.tar.gz
Fix bugs about computing durations in the column view.
* org-colview.el (org-columns-string-to-number): When computing the values for the colview, match durations and convert them to HH:MM values. * org.el (org-duration-string-to-minutes): Match non-round numbers. Add a new optional parameter to allow returning the output as a string. Thanks to Sébastien for reporting these bugs.
-rw-r--r--lisp/org-colview.el8
-rw-r--r--lisp/org.el7
2 files changed, 12 insertions, 3 deletions
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 5409701..0307402 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -1083,6 +1083,14 @@ Don't set this, this is meant for dynamic scoping.")
(while l
(setq sum (+ (string-to-number (pop l)) (/ sum 60))))
sum))
+ ((string-match (concat "\\([0-9.]+\\) *\\("
+ (regexp-opt (mapcar 'car org-effort-durations))
+ "\\)") s)
+ (setq s (concat "0:" (org-duration-string-to-minutes s t)))
+ (let ((l (nreverse (org-split-string s ":"))) (sum 0.0))
+ (while l
+ (setq sum (+ (string-to-number (pop l)) (/ sum 60))))
+ sum))
((memq fmt '(checkbox checkbox-n-of-m checkbox-percent))
(if (equal s "[X]") 1. 0.000001))
((memq fmt '(estimate)) (org-string-to-estimate s))
diff --git a/lisp/org.el b/lisp/org.el
index 81da289..8776664 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16368,7 +16368,7 @@ effort string \"2hours\" is equivalent to 120 minutes."
:type '(alist :key-type (string :tag "Modifier")
:value-type (number :tag "Minutes")))
-(defun org-duration-string-to-minutes (s)
+(defun org-duration-string-to-minutes (s &optional output-to-string)
"Convert a duration string S to minutes.
A bare number is interpreted as minutes, modifiers can be set by
@@ -16377,15 +16377,16 @@ customizing `org-effort-durations' (which see).
Entries containing a colon are interpreted as H:MM by
`org-hh:mm-string-to-minutes'."
(let ((result 0)
- (re (concat "\\([0-9]+\\) *\\("
+ (re (concat "\\([0-9.]+\\) *\\("
(regexp-opt (mapcar 'car org-effort-durations))
"\\)")))
(while (string-match re s)
(incf result (* (cdr (assoc (match-string 2 s) org-effort-durations))
(string-to-number (match-string 1 s))))
(setq s (replace-match "" nil t s)))
+ (setq result (floor result))
(incf result (org-hh:mm-string-to-minutes s))
- result))
+ (if output-to-string (number-to-string result) result)))
;;;; Files