From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lawrence Mitchell Subject: Re: Does Effort support hours only? Date: Mon, 21 Feb 2011 09:47:54 +0000 Message-ID: References: <87sjvlg1h1.fsf@gnu.org> <80pqqp4qss.fsf@missioncriticalit.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=50587 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PrSNR-0004g8-LS for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 04:48:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PrSNK-0004xI-Ll for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 04:48:15 -0500 Received: from lo.gmane.org ([80.91.229.12]:53845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PrSNK-0004x5-8z for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 04:48:14 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PrSNF-0004Qe-L7 for emacs-orgmode@gnu.org; Mon, 21 Feb 2011 10:48:09 +0100 Received: from e4300lm.epcc.ed.ac.uk ([129.215.63.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Feb 2011 10:48:09 +0100 Received: from wence by e4300lm.epcc.ed.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Feb 2011 10:48:09 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Herbert Sitz wrote: > Lawrence Mitchell gmx.li> writes: >>>>> Is it possible to specify estimated effort in something other than hours >>>>> (0.5, or 0:30)? >>> Being able to specify suffixes like `d' for days or `w' for weeks would be >>> awesome. But I guess it's very, very complex, though. >> Turns out probably not, unless I've missed something. I think >> this set of patches does what's necessary to allow duration >> strings in effort properties. And as a bonus its backwards >> compatible to the old style. Try it and see if it works, if it >> does I'll roll it into a proper patch. > Lawrence -- > I didn't test the patch, but it looks like it's hard coded to > treat 24 hours as 1 day, 168 hours as 1 week, etc. This seems > like it would create more confusion than there was before. > In the context of measuring effort I think it's far more common > to treat, e.g, 8 hours as the equivalent of a day's work. Most > people have 5 day works weeks, but some don't. Etc. In any > case, giving user ability to set their own conversion factors > seems like a much-needed part of this. That is true. The hard-coded values were just as an example. It would be reasonably trivial to introduce a variable that encoded the number of hours a day's effort would contain. The patch was just an example that the changes would not be too sweeping. In fact, here's a patch on top that would allow user-customization: diff --git a/lisp/org.el b/lisp/org.el index 2027809..c3373fa 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15473,27 +15473,41 @@ If no number is found, the return value is 0." (string-to-number (match-string 1 s))) (t 0))) +(defcustom org-effort-durations + `(("h" . 60) + ("d" . ,(* 60 8)) + ("w" . ,(* 60 8 5)) + ("m" . ,(* 60 8 5 4)) + ("y" . ,(* 60 8 5 40))) + "Conversion factor to minutes for an effort modifier. + +Each entry has the form (MODIFIER . MINUTES). + +In an effort string, a number followed by MODIFIER is multiplied +by the specified number of MINUTES to obtain an effort in +minutes. + +For example, if the value of this variable is ((\"hours\" . 60)), then an +effort string \"2hours\" is equivalent to 120 minutes." + :group 'org-agenda + :type '(alist :key-type (string :tag "Modifier") + :value-type (number :tag "Minutes"))) + (defun org-duration-string-to-minutes (s) "Convert a duration string S to minutes. -A bare number is interpreted as minutes, the following suffixes are -recognised: - h - hours - d - days - w - weeks (7 days) - m - months (30 days) - y - years (365 days) +A bare number is interpreted as minutes, modifiers can be set by +customizing `org-effort-durations' (which see). Entries containing a colon are interpreted as H:MM by `org-hh:mm-string-to-minutes'." - (let ((conversion `(("h" . 60) - ("d" . ,(* 60 24)) - ("w" . ,(* 60 24 7)) - ("m" . ,(* 60 24 7 30)) - ("y" . ,(* 60 24 7 365)))) - (result 0)) - (while (string-match "\\([0-9]+\\)\\([hdwmy]\\)" s) - (incf result (* (cdr (assoc (match-string 2 s) conversion)) + (let ((result 0) + (regex (rx (group (1+ (any "0-9"))) + (0+ (syntax whitespace)) + (group + (eval (cons 'or (mapcar 'car org-effort-durations))))))) + (while (string-match regex 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))) (incf result (org-hh:mm-string-to-minutes s)) -- Lawrence Mitchell