emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [bug] Remote durations are considered as fractions


From: Sebastien Vauban
Subject: Re: [O] [bug] Remote durations are considered as fractions
Date: Wed, 02 May 2012 12:32:13 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.1.50 (windows-nt)

Hi Bastien,

Bastien wrote:
> "Sebastien Vauban" writes:
>
>> I think this is it...
>
> Yes.. but in fact, this is precisely the difference between the `t' and the
> `T' flags - the latter displays seconds while the former display the output
> according to `org-table-duration-custom-format', which you can customize.
> Sorry I didn't mention this before.

I have the impression you mixed, in the above, seconds with *fraction of*
seconds:

- the flag `T' currently means HH:MM:SS, while
- the flag `t' currently means "fractional time" of hours (by default).

As you say, `t' may be further customized:

    ┏━━━━
    ┃ org-table-duration-custom-format is a variable defined in `org-table.el'.
    ┃ Its value is hours
    ┃ 
    ┃ Documentation:
    ┃ Format for the output of calc computations like $1+$2;t.
    ┃ The default value is 'hours, and will output the results as a
    ┃ number of hours.  Other allowed values are 'seconds, 'minutes and
    ┃ 'days, and the output will be a fraction of seconds, minutes or
    ┃ days.
    ┗━━━━

Hence, you really have 5 cases:

- t, fraction of days
- t, fraction of hours
- t, fraction of minutes
- t, fraction of seconds
- T, HH:MM:SS

Those 5 cases are currently handled (in that order) in the following function:

--8<---------------cut here---------------start------------->8---
(defun org-table-time-seconds-to-string (secs &optional output-format)
  "Convert a number of seconds to a time string.
If OUTPUT-FORMAT is non-nil, return a number of days, hours,
minutes or seconds."
  (let* ((secs0 (abs secs))
         (res
          (cond ((eq output-format 'days)
                 (format "%.3f" (/ (float secs0) 86400)))
                ((eq output-format 'hours)
                 (format "%.2f" (/ (float secs0) 3600)))
                ((eq output-format 'minutes)
                 (format "%.1f" (/ (float secs0) 60)))
                ((eq output-format 'seconds)
                 (format "%d" secs0))
                (t (org-format-seconds "%.2h:%.2m:%.2s" secs0)))))
    (if (< secs 0) (concat "-" res) res)))
--8<---------------cut here---------------end--------------->8---

My patch just addressed the HH:MM:SS format (that is, the `T' flag).
It does not impact the fractional representation of time (the `t' flag).

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

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