Re: Calc/TBLFM: how to conditionally insert hours:minutes?
Hi Bruno, > You could switch to the "Lisp" syntax (as opposed to the "Calc" syntax), > and, write the conversion manually: > > | 19:55:00 | > | 40:01:00 | > | 40:01:00 | > > #+TBLFM: $1='(org-table-time-string-to-seconds (if (<= @# 1) "19:55" > "40:01"));T awesome, thank out. This works as expected with the little addendum that @# in Calc seems to ignore the header line (not present in this example), but the Lispy syntax doesn't. So the 1 in the "if" becomes a 2. > Note that, for Calc, 'X:Y' means the fraction 'X/Y' of the two > integers X and Y: > >40:01 = 40/1 = 40 >40:02 = 40/2 = 20 >40:03 = 40/3 >40:04 = 40/4 = 10 This also explains why 40:00 errors out :) Thanks a lot Chris
Re: Calc/TBLFM: how to conditionally insert hours:minutes?
Hi Chris, Chris Keschnat writes: > > | 19:55:00 | > | 00:00:40 | > | 00:00:40 | > #+TBLFM: $1=if(@# <= 1, 19:55, 40:01);T > > What would be the correct way to do this? > It seems that org tries to convert times back and forth when evaluating formulas; but, in your case, it cannot convert them because it doesn't spot them inside your formula. You could switch to the "Lisp" syntax (as opposed to the "Calc" syntax), and, write the conversion manually: | 19:55:00 | | 40:01:00 | | 40:01:00 | #+TBLFM: $1='(org-table-time-string-to-seconds (if (<= @# 1) "19:55" "40:01"));T Note that, for Calc, 'X:Y' means the fraction 'X/Y' of the two integers X and Y: 40:01 = 40/1 = 40 40:02 = 40/2 = 20 40:03 = 40/3 40:04 = 40/4 = 10 Bruno
Calc/TBLFM: how to conditionally insert hours:minutes?
Hi, I am trying to understand how to set hours:minutes values in tables conditionally. Just setting hours directly works: | 40:03:00 | | 40:03:00 | | 40:03:00 | #+TBLFM: $1=40:03;T But when doing that conditionally (first row different from the others), I do not understand the behavior: This seemed to work: | 19:55:00 | | 40:03:00 | | 40:03:00 | #+TBLFM: $1=if(@# <= 1, 19:55, 40:03);T But after adjusting the minutes, this happens: | 19:55:00 | | 00:00:40 | | 00:00:40 | #+TBLFM: $1=if(@# <= 1, 19:55, 40:01);T What would be the correct way to do this? PS: I have found that the same happens when I add parentheses: | 40:03:00 | | 40:03:00 | | 40:03:00 | #+TBLFM: $1=(40:03);T | 00:00:40 | | 00:00:40 | | 00:00:40 | #+TBLFM: $1=(40:01);T PPS: I came across this when trying to understand the formulas here https://github.com/clange/org-mode Thanks Chris