From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: Re: [PATCH] Separate clocksum format for durations >= 1 day Date: Thu, 8 Nov 2012 12:28:57 +0100 Message-ID: <20121108112857.GA4911@c3po> References: <87wqxxkkhj.fsf@gmail.com> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWQHw-0006c3-RZ for emacs-orgmode@gnu.org; Thu, 08 Nov 2012 06:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWQHp-0004Jw-My for emacs-orgmode@gnu.org; Thu, 08 Nov 2012 06:28:48 -0500 Received: from sanddollar.geekisp.com ([216.168.135.167]:41002) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TWQHp-0004Jg-HL for emacs-orgmode@gnu.org; Thu, 08 Nov 2012 06:28:41 -0500 Content-Disposition: inline In-Reply-To: <87wqxxkkhj.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org On Thu, Nov 08, 2012 at 01:26:48AM +0100, Nicolas Goaziou wrote: > Format string for clock lines is hard-coded (see line 1493 in > org-clock.el), which means we don't have to limit ourselves to > parse-able format. Back to point 1. Good. That's what I thought. > Then, I'm fine with format strings. Following your suggestion, what > about the following variables: > - one to determine format of data: fractional or regular. > - one to determine display format. Its value would be a list of 3 format > strings associated to days, hours and minutes. Sounds good to me. I think your idea of separating out the format strings for days, hours and minutes is better. Minor point: I would order the format strings minutes, hours, days. In case we ever want to extend to months or years, that way we can simply extend the list and it will be completely backwards compatible. One other thing that needs some thought (which I already mentioned previously). The minutes format string needs to change, depending on whether the data format is fractional or regular. So if a user wants to switch to fractional, it's not enough to set the first variable; they have to *also* change the minute format string. If they don't the durations will be garbled. A customization setter function could be used to change the value of the second variable when the first one is modified through customize. But that quickly gets complex, e.g. we have to be careful about clobbering any customizations the user has already made to the format strings. The simpler solution would be to always have two format strings for the minutes in the list: a fractional format, and a regular format. This shouldn't be too confusing as long as it's documented in the variable docstring and there are good descriptive :tags for each list element in the customization type. > Internally, the duration is computed as a list of three integers or nil > if data is regular, or a list of one float and two nil if data is > fractional. Format strings from the second variable will be concatenated > only when value is non-nil. If no format string is found for a given > unit, it's value will be converted into a lesser unit. > > Examples: > > | var1 | var2 | internal representation | display | > |-------------+-----------------------------+-------------------------+-------------| > | 'regular | ("%dd " "%d h " "%d min") | (nil 11 35) | 11 h 35 min | > | 'fractional | ("%.2fd" "%.2fh" "%.2fmin") | (nil 11.3 nil) | 11.30h | > | 'regular | ("%dd " "%d:" "%02d") | (1 3 5) | 1d 3:05 | > | 'regular | (nil "%d:" "%02d") | (1 3 5) | 27:05 | > > We can extend it to years if needed. Looks good to me, and lets me do what I wanted in my original patch. Now I just need to find time to code it up... Best, 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