From: "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: [bug] Remote durations are considered as fractions
Date: Wed, 09 May 2012 21:16:29 +0200 [thread overview]
Message-ID: <80y5p1b1wy.fsf@somewhere.org> (raw)
In-Reply-To: 80pqamq3f6.fsf@somewhere.org
Hi Bastien,
"Sebastien Vauban" wrote:
> 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:
>
> (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)))
>
> 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).
I just had to look at some table using time references :
| 08:30 | 09:00 |
| 09:30 | |
As the end time on the first line is equal to the beginning time on the second
one, I try using a formula to copy the time:
| 08:30 | 09:00 |
| #ERROR | |
#+TBLFM: @2$1=@1$2
The above does not work because Calc makes a division of 9 by 0, as -- by
default, without an explicit format -- data is considered as numeric, right?
Hence, I need to use the T flag, but this doesn't look right yet:
| 08:30 | 09:00 |
| 09:00:00 | |
#+TBLFM: @2$1=@1$2;T
This is what the above patch is supposed to solve.
BTW, I tried other variants:
1. replacing `:' by `h'
| 08h30 | 09h00 |
| 9 h00 | |
#+TBLFM: @2$1=@1$2
Weird that the 9 is moved away from the `h'. I can accept that the leading
0 is removed, though.
2. ... and using a string format:
| 8h30 | 9h00 |
| 9 | |
#+TBLFM: @2$1=@1$2;%s
Another weird results for me...
Isn't there any way to say "copy verbatim the contents" of that field?
Best regards,
Seb
--
Sebastien Vauban
next prev parent reply other threads:[~2012-05-09 19:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 12:35 [bug] Remote durations are considered as fractions Sebastien Vauban
2012-04-10 22:46 ` Bastien
2012-04-19 13:19 ` Sebastien Vauban
2012-04-20 11:21 ` Bastien
2012-04-20 20:45 ` Sebastien Vauban
2012-04-20 23:22 ` Bastien
2012-05-02 10:32 ` Sebastien Vauban
2012-05-09 19:16 ` Sebastien Vauban [this message]
2012-06-04 15:02 ` Sebastien Vauban
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=80y5p1b1wy.fsf@somewhere.org \
--to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
--cc=emacs-orgmode-mXXj517/zsQ@public.gmane.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).