[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calc/TBLFM: how to conditionally insert hours:minutes?
From: |
Bruno Barbier |
Subject: |
Re: Calc/TBLFM: how to conditionally insert hours:minutes? |
Date: |
Mon, 25 Sep 2023 11:32:18 +0200 |
Hi Chris,
Chris Keschnat <chris@catsu.it> 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