emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Chris Keschnat <chris@catsu.it>
To: emacs-orgmode@gnu.org
Subject: Re: Calc/TBLFM: how to conditionally insert hours:minutes?
Date: Mon, 25 Sep 2023 19:36:53 +0200	[thread overview]
Message-ID: <87r0mmb159.fsf@catsu.it> (raw)
In-Reply-To: <651153a4.7b0a0220.f4676.c846@mx.google.com>


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


      reply	other threads:[~2023-09-25 17:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-23 19:38 Calc/TBLFM: how to conditionally insert hours:minutes? Chris Keschnat
2023-09-25  9:32 ` Bruno Barbier
2023-09-25 17:36   ` Chris Keschnat [this message]

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=87r0mmb159.fsf@catsu.it \
    --to=chris@catsu.it \
    --cc=emacs-orgmode@gnu.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).