summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Egli <christian.egli@alumni.ethz.ch>2010-03-24 12:02:37 +0100
committerChristian Egli <christian.egli@alumni.ethz.ch>2010-06-08 09:20:33 +0200
commitd073c313aa5ac1752ab678a56bf15b368259e1e8 (patch)
treea434d95a941e33462e3c06e87a33b8155f6d2777
parent3e0ce7b355b4c1d05707d09eb1a12f496bf0308e (diff)
downloadorg-mode-d073c313aa5ac1752ab678a56bf15b368259e1e8.tar.gz
Fix a problem with effort calculation based on hh:mm efforts
-rw-r--r--lisp/org-taskjuggler.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el
index fc2b89a..dca56a1 100644
--- a/lisp/org-taskjuggler.el
+++ b/lisp/org-taskjuggler.el
@@ -417,16 +417,17 @@ If the ATTRIBUTE is not in ITEM return nil."
(defun org-taskjuggler-clean-effort (effort)
"Translate effort strings into a format acceptable to taskjuggler,
-i.e. REAL UNIT. If the effort string is something like 5:00 it
-will be assumed to be hours and will be translated into 5.0h.
+i.e. REAL UNIT. If the effort string is something like 5:30 it
+will be assumed to be hours and will be translated into 5.5h.
Otherwise if it contains something like 3.0 it is assumed to be
days and will be translated into 3.0d. Other formats that taskjuggler
supports (like weeks, months and years) are currently not supported."
(cond
((null effort) effort)
((string-match "\\([0-9]+\\):\\([0-9]+\\)" effort)
- ; FIXME: translate the minutes to a decimal
- (concat (match-string 1 effort) "." (match-string 2 effort) "h"))
+ (let ((hours (string-to-number (match-string 1 effort)))
+ (minutes (string-to-number (match-string 2 effort))))
+ (format "%dh" (+ hours (/ minutes 60.0)))))
((string-match "\\([0-9]+\\).\\([0-9]+\\)" effort) (concat effort "d"))
(t (error "Not a valid effort (%s)" effort))))