From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Re: [bug] Remote durations are considered as fractions Date: Mon, 04 Jun 2012 17:02:19 +0200 Message-ID: <80pq9ft91g.fsf@somewhere.org> References: <80mx6t2dt7.fsf@somewhere.org> <87y5q3b3xf.fsf@gnu.org> <80hawfj1tu.fsf@somewhere.org> <87ty0ezm0w.fsf@altern.org> <8062cunncw.fsf@somewhere.org> <87k41agfae.fsf@altern.org> <80pqamq3f6.fsf@somewhere.org> <80y5p1b1wy.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi, May I bump up this thread (and its inlined, older, corollary)? Best regards, Seb "Sebastien Vauban" wrote: > "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 ou= tput >>> according to `org-table-duration-custom-format', which you can customiz= e. >>> 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: >> >> =E2=94=8F=E2=94=81=E2=94=81=E2=94=81=E2=94=81 >> =E2=94=83 org-table-duration-custom-format is a variable defined in = `org-table.el'. >> =E2=94=83 Its value is hours >> =E2=94=83=20 >> =E2=94=83 Documentation: >> =E2=94=83 Format for the output of calc computations like $1+$2;t. >> =E2=94=83 The default value is 'hours, and will output the results a= s a >> =E2=94=83 number of hours. Other allowed values are 'seconds, 'minu= tes and >> =E2=94=83 'days, and the output will be a fraction of seconds, minut= es or >> =E2=94=83 days. >> =E2=94=97=E2=94=81=E2=94=81=E2=94=81=E2=94=81 >> >> 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 fun= ction: >> >> (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=C2=A0: > > | 08:30 | 09:00 | > | 09:30 | | > > As the end time on the first line is equal to the beginning time on the s= econd > one, I try using a formula to copy the time: > > | 08:30 | 09:00 | > | #ERROR | | > #+TBLFM: @2$1=3D@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, rig= ht? > > 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=3D@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=3D@1$2 > > Weird that the 9 is moved away from the `h'. I can accept that the lea= ding > 0 is removed, though. > > 2. ... and using a string format: > > | 8h30 | 9h00 | > | 9 | | > #+TBLFM: @2$1=3D@1$2;%s > > Another weird results for me... > > Isn't there any way to say "copy verbatim the contents" of that field? --=20 Sebastien Vauban