emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Toby Cubitt <tsc25@cantab.net>
To: Mike McLean <mike.mclean@pobox.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Separate clocksum format for durations >= 1 day
Date: Tue, 20 Nov 2012 18:28:19 +0100	[thread overview]
Message-ID: <20121120172819.GA1640@c3po> (raw)
In-Reply-To: <CANid5Q48skecNHP5hs0=Mt9SzVjHsheeB3sbpiqse5RMQ8hXYw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]

On Tue, Nov 20, 2012 at 11:12:10AM -0500, Mike McLean wrote:
> On Sat, Nov 17, 2012 at 11:02 AM, Toby Cubitt <tsc25@cantab.net> wrote:
> 
> > On Sat, Nov 17, 2012 at 03:42:24PM +0100, Nicolas Goaziou wrote:
> > > Toby Cubitt <tsc25@cantab.net> writes:
> > >
> > > > I've replaced the cons cells with additional plist properties, as you
> > > > suggested. The resulting customization ui still isn't wonderful in my
> > > > opinion. But it does the job, and I'm not sure how much scope there is
> > > > for improving it further. If you see a way, by all means feel free to
> > > > make the changes yourself. I really don't mind what format you go with
> > > > for org-time-clocksum-format, as long as it supports the new formatting
> > > > features implemented in the patch.
> > >
> > > Considering I'm not an expert in customize ui, it's good enough as it
> > > is.
> >
> > OK. If someone thinks of a way to improve the customization ui (keeping
> > the same data type), it's easy to change it later without breaking
> > anything.
> >
> > > I've applied your patch (with some small changes in a docstring). Thank
> > > you again for all that work.
> >
> > Glad we finally found a good implementation. Thanks to you for all your
> > helpful feedback.
> >
> >
> I like the new implementation and customization options, but now when I do
> ~C-c C-x C-c~ to get a sub-tree time, I get nothing but zeros (~0d 0:00~)
> for every subtree.

Argh. This is a bug in org-hours-to-clocksum-string, which doesn't
truncate the computed number of minutes to an integer.

Instead of changing org-hours-to-clocksum-string, it's probably
preferable to make org-minutes-to-clocksum-string more robust, so it
copes correctly with floating point arguments.

The attached patch does this. Sorry for letting this slip through.

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: tsc25@cantab.net
web:   www.dr-qubit.org

[-- Attachment #2: 0001-Fix-org-minutes-to-clocksum-string-to-cope-with-floa.patch --]
[-- Type: text/x-patch, Size: 3372 bytes --]

From 24c646916a1195b3291067ef6e54d9e99a1201da Mon Sep 17 00:00:00 2001
From: "Toby S. Cubitt" <tsc25@cantab.net>
Date: Tue, 20 Nov 2012 18:15:21 +0100
Subject: [PATCH] Fix org-minutes-to-clocksum-string to cope with floating
 point arguments.

---
 lisp/org.el |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index dc411b8..e3354c6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16773,19 +16773,19 @@ The format is determined by `org-time-clocksum-format',
 	  (format org-time-clocksum-fractional-format (/ m 60.0)))
 	 ;; choice of fractional formats for different time units
 	 ((and (setq fmt (plist-get org-time-clocksum-fractional-format :years))
-	       (> (/ m (* 365 24 60)) 0))
+	       (> (/ (truncate m) (* 365 24 60)) 0))
 	  (format fmt (/ m (* 365 24 60.0))))
 	 ((and (setq fmt (plist-get org-time-clocksum-fractional-format :months))
-	       (> (/ m (* 30 24 60)) 0))
+	       (> (/ (truncate m) (* 30 24 60)) 0))
 	  (format fmt (/ m (* 30 24 60.0))))
 	 ((and (setq fmt (plist-get org-time-clocksum-fractional-format :weeks))
-	       (> (/ m (* 7 24 60)) 0))
+	       (> (/ (truncate m) (* 7 24 60)) 0))
 	  (format fmt (/ m (* 7 24 60.0))))
 	 ((and (setq fmt (plist-get org-time-clocksum-fractional-format :days))
-	       (> (/ m (* 24 60)) 0))
+	       (> (/ (truncate m) (* 24 60)) 0))
 	  (format fmt (/ m (* 24 60.0))))
 	 ((and (setq fmt (plist-get org-time-clocksum-fractional-format :hours))
-	       (> (/ m 60) 0))
+	       (> (/ (truncate m) 60) 0))
 	  (format fmt (/ m 60.0)))
 	 ((setq fmt (plist-get org-time-clocksum-fractional-format :minutes))
 	  (format fmt m))
@@ -16805,27 +16805,27 @@ The format is determined by `org-time-clocksum-format',
 	  (format org-time-clocksum-format (setq n (/ m 60)) (- m (* 60 n)))
 	;; separate formats components
 	(and (setq fmt (plist-get org-time-clocksum-format :years))
-	     (or (> (setq n (/ m (* 365 24 60))) 0)
+	     (or (> (setq n (/ (truncate m) (* 365 24 60))) 0)
 		 (plist-get org-time-clocksum-format :require-years))
 	     (setq clocksum (concat clocksum (format fmt n))
 		   m (- m (* n 365 24 60))))
 	(and (setq fmt (plist-get org-time-clocksum-format :months))
-	     (or (> (setq n (/ m (* 30 24 60))) 0)
+	     (or (> (setq n (/ (truncate m) (* 30 24 60))) 0)
 		 (plist-get org-time-clocksum-format :require-months))
 	     (setq clocksum (concat clocksum (format fmt n))
 		   m (- m (* n 30 24 60))))
 	(and (setq fmt (plist-get org-time-clocksum-format :weeks))
-	     (or (> (setq n (/ m (* 7 24 60))) 0)
+	     (or (> (setq n (/ (truncate m) (* 7 24 60))) 0)
 		 (plist-get org-time-clocksum-format :require-weeks))
 	     (setq clocksum (concat clocksum (format fmt n))
 		   m (- m (* n 7 24 60))))
 	(and (setq fmt (plist-get org-time-clocksum-format :days))
-	     (or (> (setq n (/ m (* 24 60))) 0)
+	     (or (> (setq n (/ (truncate m) (* 24 60))) 0)
 		 (plist-get org-time-clocksum-format :require-days))
 	     (setq clocksum (concat clocksum (format fmt n))
 		   m (- m (* n 24 60))))
 	(and (setq fmt (plist-get org-time-clocksum-format :hours))
-	     (or (> (setq n (/ m 60)) 0)
+	     (or (> (setq n (/ (truncate m) 60)) 0)
 		 (plist-get org-time-clocksum-format :require-hours))
 	     (setq clocksum (concat clocksum (format fmt n))
 		   m (- m (* n 60))))
-- 
1.7.8.6


  reply	other threads:[~2012-11-20 17:28 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-27 14:01 [PATCH] Separate clocksum format for durations >= 1 day Toby Cubitt
2012-11-05  9:14 ` Nicolas Goaziou
2012-11-05 10:25   ` Toby Cubitt
2012-11-05 10:47   ` Achim Gratz
2012-11-05 11:01     ` Toby Cubitt
2012-11-05 11:13       ` Achim Gratz
2012-11-05 12:10         ` Toby Cubitt
2012-11-05 12:20           ` Nicolas Goaziou
2012-11-05 12:55             ` Toby Cubitt
2012-11-05 13:14               ` Nicolas Goaziou
2012-11-05 17:40                 ` Achim Gratz
2012-11-05 18:16                   ` Toby Cubitt
2012-11-05 22:45                     ` Nicolas Goaziou
2012-11-06 10:35                       ` Toby Cubitt
2012-11-06 10:57                         ` Nicolas Goaziou
2012-11-06 12:01                           ` Toby Cubitt
2012-11-06 12:29                             ` Nicolas Goaziou
2012-11-06 13:04                               ` Toby Cubitt
2012-11-06 17:41                                 ` Nicolas Goaziou
2012-11-06 19:26                                   ` Toby Cubitt
2012-11-06 19:55                                     ` Nicolas Goaziou
2012-11-06 20:35                                       ` Toby Cubitt
2012-11-08  0:26                                         ` Nicolas Goaziou
2012-11-08 11:28                                           ` Toby Cubitt
2012-11-09  8:04                                             ` Nicolas Goaziou
2012-11-13 13:03                                               ` Toby Cubitt
2012-11-14 15:04                                                 ` Nicolas Goaziou
2012-11-14 15:37                                                   ` Toby Cubitt
2012-11-14 16:09                                                     ` Nicolas Goaziou
2012-11-14 16:20                                                       ` Toby Cubitt
2012-11-16 15:12                                                         ` Toby Cubitt
2012-11-17  8:48                                                           ` Nicolas Goaziou
2012-11-17 14:00                                                             ` Toby Cubitt
2012-11-17 14:42                                                               ` Nicolas Goaziou
2012-11-17 16:02                                                                 ` Toby Cubitt
2012-11-20 16:12                                                                   ` Mike McLean
2012-11-20 17:28                                                                     ` Toby Cubitt [this message]
2012-11-20 19:24                                                                       ` Nicolas Goaziou
2012-11-21 23:29                                                                         ` Mike McLean
2012-11-30 11:22                                                                 ` [bug] " Sebastien Vauban
2012-11-06 18:42                       ` [PATCH] " Achim Gratz
2012-11-06 20:10                         ` Toby Cubitt
2012-11-06 20:49                           ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121120172819.GA1640@c3po \
    --to=tsc25@cantab.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mike.mclean@pobox.com \
    --cc=toby-dated-1354642084.5d7288@dr-qubit.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).