From 9c31d781e9e770a584a9fc04737d3fd352f6a40b Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 5 Jan 2013 18:21:55 +0100 Subject: [PATCH] New option `org-time-clocksum-use-effort-durations' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * org.el (org-time-clocksum-format): Add a version tag and add to the 'org-clock group. (org-time-clocksum-use-fractional): Ditto. (org-time-clocksum-use-effort-durations): New option to allow using `org-effort-durations' when computing clocksum durations. (org-minutes-to-clocksum-string): Use the new option. * org-clock.el (org-clocktable-write-default): Let-bind `org-time-clocksum-use-effort-durations' to a new clocktable parameter ":effort-durations". Thanks to Sébastien Vauban for pointing the inconsistency. --- lisp/org-clock.el | 2 ++ lisp/org.el | 90 ++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 83ff459..5e74332 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2316,6 +2316,8 @@ from the dynamic block definition." (maxlevel (or (plist-get params :maxlevel) 3)) (emph (plist-get params :emphasize)) (level-p (plist-get params :level)) + (org-time-clocksum-use-effort-durations + (plist-get params :effort-durations)) (timestamp (plist-get params :timestamp)) (properties (plist-get params :properties)) (ntcol (max 1 (or (plist-get params :tcolumns) 100))) diff --git a/lisp/org.el b/lisp/org.el index 78429a7..88d13a0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2774,6 +2774,8 @@ means durations longer than a day will be expressed in days and minutes, and durations less than a day will be expressed entirely in minutes (even for durations longer than an hour)." :group 'org-time + :group 'org-clock + :version "24.3" :type '(choice (string :tag "Format string") (set :tag "Plist" (group :inline t (const :tag "Years" :years) @@ -2808,9 +2810,24 @@ in minutes (even for durations longer than an hour)." (const t))))) (defcustom org-time-clocksum-use-fractional nil - "If non-nil, \\[org-clock-display] uses fractional times. -org-mode generates a time duration." + "When non-nil, \\[org-clock-display] uses fractional times. +See `org-time-clocksum-format' for more on time clock formats." :group 'org-time + :group 'org-clock + :version "24.3" + :type 'boolean) + +(defcustom org-time-clocksum-use-effort-durations t + "When non-nil, \\[org-clock-display] uses effort durations. +E.g. by default, one day is considered to be a 8 hours effort, +so a task that has been clocked for 16 hours will be displayed +as during 2 days in the clock display or in the clocktable. + +See `org-effort-durations' on how to set effort durations +and `org-time-clocksum-format' for more on time clock formats." + :group 'org-time + :group 'org-clock + :version "24.3" :type 'boolean) (defcustom org-time-clocksum-fractional-format "%.2f" @@ -16873,72 +16890,83 @@ If there is already a time stamp at the cursor position, update it." "Format number of minutes as a clocksum string. The format is determined by `org-time-clocksum-format', `org-time-clocksum-use-fractional' and -`org-time-clocksum-fractional-format'." - (let ((clocksum "") fmt n) +`org-time-clocksum-fractional-format' and +`org-time-clocksum-use-effort-durations'." + (let ((clocksum "") h d w mo y fmt n) + (setq h (if org-time-clocksum-use-effort-durations + (cdr (assoc "h" org-effort-durations)) 60) + d (if org-time-clocksum-use-effort-durations + (/ (cdr (assoc "d" org-effort-durations)) h) 24) + w (if org-time-clocksum-use-effort-durations + (/ (cdr (assoc "w" org-effort-durations)) (* d h)) 7) + mo (if org-time-clocksum-use-effort-durations + (/ (cdr (assoc "m" org-effort-durations)) (* d h)) 30) + y (if org-time-clocksum-use-effort-durations + (/ (cdr (assoc "y" org-effort-durations)) (* d h)) 365)) ;; fractional format (if org-time-clocksum-use-fractional (cond ;; single format string ((stringp org-time-clocksum-fractional-format) - (format org-time-clocksum-fractional-format (/ m 60.0))) + (format org-time-clocksum-fractional-format (/ m (float h)))) ;; choice of fractional formats for different time units ((and (setq fmt (plist-get org-time-clocksum-fractional-format :years)) - (> (/ (truncate m) (* 365 24 60)) 0)) - (format fmt (/ m (* 365 24 60.0)))) + (> (/ (truncate m) (* y d h)) 0)) + (format fmt (/ m (* y d (float h))))) ((and (setq fmt (plist-get org-time-clocksum-fractional-format :months)) - (> (/ (truncate m) (* 30 24 60)) 0)) - (format fmt (/ m (* 30 24 60.0)))) + (> (/ (truncate m) (* mo d h)) 0)) + (format fmt (/ m (* mo d (float h))))) ((and (setq fmt (plist-get org-time-clocksum-fractional-format :weeks)) - (> (/ (truncate m) (* 7 24 60)) 0)) - (format fmt (/ m (* 7 24 60.0)))) + (> (/ (truncate m) (* w d h)) 0)) + (format fmt (/ m (* w d (float h))))) ((and (setq fmt (plist-get org-time-clocksum-fractional-format :days)) - (> (/ (truncate m) (* 24 60)) 0)) - (format fmt (/ m (* 24 60.0)))) + (> (/ (truncate m) (* d h)) 0)) + (format fmt (/ m (* d (float h))))) ((and (setq fmt (plist-get org-time-clocksum-fractional-format :hours)) - (> (/ (truncate m) 60) 0)) - (format fmt (/ m 60.0))) + (> (/ (truncate m) h) 0)) + (format fmt (/ m (float h)))) ((setq fmt (plist-get org-time-clocksum-fractional-format :minutes)) (format fmt m)) ;; fall back to smallest time unit with a format ((setq fmt (plist-get org-time-clocksum-fractional-format :hours)) - (format fmt (/ m 60.0))) + (format fmt (/ m (float h)))) ((setq fmt (plist-get org-time-clocksum-fractional-format :days)) - (format fmt (/ m (* 24 60.0)))) + (format fmt (/ m (* d (float h))))) ((setq fmt (plist-get org-time-clocksum-fractional-format :weeks)) - (format fmt (/ m (* 7 24 60.0)))) + (format fmt (/ m (* w d (float h))))) ((setq fmt (plist-get org-time-clocksum-fractional-format :months)) - (format fmt (/ m (* 30 24 60.0)))) + (format fmt (/ m (* mo d (float h))))) ((setq fmt (plist-get org-time-clocksum-fractional-format :years)) - (format fmt (/ m (* 365 24 60.0))))) + (format fmt (/ m (* y d (float h)))))) ;; standard (non-fractional) format, with single format string (if (stringp org-time-clocksum-format) - (format org-time-clocksum-format (setq n (/ m 60)) (- m (* 60 n))) + (format org-time-clocksum-format (setq n (/ m h)) (- m (* h n))) ;; separate formats components (and (setq fmt (plist-get org-time-clocksum-format :years)) - (or (> (setq n (/ (truncate m) (* 365 24 60))) 0) + (or (> (setq n (/ (truncate m) (* y d h))) 0) (plist-get org-time-clocksum-format :require-years)) (setq clocksum (concat clocksum (format fmt n)) - m (- m (* n 365 24 60)))) + m (- m (* n y d h)))) (and (setq fmt (plist-get org-time-clocksum-format :months)) - (or (> (setq n (/ (truncate m) (* 30 24 60))) 0) + (or (> (setq n (/ (truncate m) (* mo d h))) 0) (plist-get org-time-clocksum-format :require-months)) (setq clocksum (concat clocksum (format fmt n)) - m (- m (* n 30 24 60)))) + m (- m (* n mo d h)))) (and (setq fmt (plist-get org-time-clocksum-format :weeks)) - (or (> (setq n (/ (truncate m) (* 7 24 60))) 0) + (or (> (setq n (/ (truncate m) (* w d h))) 0) (plist-get org-time-clocksum-format :require-weeks)) (setq clocksum (concat clocksum (format fmt n)) - m (- m (* n 7 24 60)))) + m (- m (* n w d h)))) (and (setq fmt (plist-get org-time-clocksum-format :days)) - (or (> (setq n (/ (truncate m) (* 24 60))) 0) + (or (> (setq n (/ (truncate m) (* d h))) 0) (plist-get org-time-clocksum-format :require-days)) (setq clocksum (concat clocksum (format fmt n)) - m (- m (* n 24 60)))) + m (- m (* n d h)))) (and (setq fmt (plist-get org-time-clocksum-format :hours)) - (or (> (setq n (/ (truncate m) 60)) 0) + (or (> (setq n (/ (truncate m) h)) 0) (plist-get org-time-clocksum-format :require-hours)) (setq clocksum (concat clocksum (format fmt n)) - m (- m (* n 60)))) + m (- m (* n h)))) (and (setq fmt (plist-get org-time-clocksum-format :minutes)) (or (> m 0) (plist-get org-time-clocksum-format :require-minutes)) (setq clocksum (concat clocksum (format fmt m)))) -- 1.8.0.3