[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Separate clocksum format for durations >= 1 day

From: Toby Cubitt
Subject: Re: [O] [PATCH] Separate clocksum format for durations >= 1 day
Date: Thu, 8 Nov 2012 12:28:57 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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...

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

email: address@hidden
web:   www.dr-qubit.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]