From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Halder Subject: Re: org table calc and lisp for hh:mm timetable Date: Tue, 15 Mar 2011 20:49:01 +0100 Message-ID: <0DDD90AF-9B9A-4FE3-8080-74EF01E6E292@gmail.com> References: <9999237C-1FBD-481E-AF8D-D68DB85080CE@gmail.com> <87lj0gqjd3.fsf@ucl.ac.uk> Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=44164 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzaEu-0005Ae-J1 for emacs-orgmode@gnu.org; Tue, 15 Mar 2011 15:49:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzaEs-0004Q0-8n for emacs-orgmode@gnu.org; Tue, 15 Mar 2011 15:49:08 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:41177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzaEs-0004PY-3H for emacs-orgmode@gnu.org; Tue, 15 Mar 2011 15:49:06 -0400 Received: by wwc33 with SMTP id 33so1010446wwc.30 for ; Tue, 15 Mar 2011 12:49:05 -0700 (PDT) In-Reply-To: <87lj0gqjd3.fsf@ucl.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric S Fraga Cc: emacs-orgmode@gnu.org >> I was trying to generate a simple table with time format "hh:mm" and >> auto calculate daily sum.. clocking working time was too much so I >> thought this would be easy but ended up with the following.. it works >> but is not beautiful (apply formula twice and same information >> multiple times) and I would like to get rid of the "hms", "hh" and >> "mm" columns and therefore call "hmconcat" directly somehow.. Any = help >> is highly appreciated.. >>=20 >> Thanks, >> Martin >>=20 >> | Date | Start | Lunch | Back | End | Sum | hms = | hh | mm | >> = |------------------+-------+-------+-------+-------+-------+-----------+--= --+----| >> | [2011-03-01 Tue] | 08:00 | 12:20 | 13:00 | 17:00 | 08:20 | 8@ 20' = 0" | 8 | 20 | >> #+TBLFM: $6=3D'(hmconcat $8 $9)::$7=3Dtime(<2010-01-01 = $5>)-time(<2010-01-01 $4>)+time(<2010-01-01 $3>)-time(<2010-01-01 = $2>)::$8=3Dhour($7)::$9=3Dminute($7) >>=20 >> (defun hmconcat (hh mm) (interactive) >> (if (> (length hh) 1) >> (setq temp (concat hh ":")) (setq temp (concat "0" hh ":"))) >> (if (> (length mm) 1) >> (concat temp mm) (concat temp "0" mm))) >=20 > Martin, >=20 > glad to see you got further with this! >=20 > You can definitely get rid of hmconcat by using a combination of > string-to-number and format (and I'm sure it's possible to get this = done > with simpler elisp): >=20 > --8<---------------cut here---------------start------------->8--- >=20 > | Date | Start | Lunch | Back | End | Sum | hms = | hh | mm | > = |------------------+-------+-------+-------+-------+-------+-----------+--= --+----| > | [2011-03-01 Tue] | 08:00 | 12:20 | 13:00 | 17:00 | 08:20 | 8@ 20' 0" = | 8 | 20 | > #+TBLFM: $6=3D'(format "%02d:%02d" (string-to-number $8) = (string-to-number $9))::$7=3Dtime(<2010-01-01 $5>)-time(<2010-01-01 = $4>)+time(<2010-01-01 $3>)-time(<2010-01-01 = $2>)::$8=3Dhour($7)::$9=3Dminute($7) > --8<---------------cut here---------------end--------------->8--- Hi Eric, yes and thanks for the previous help, too.. the good old printf.. I = would like to pass the result of time() directly to a lisp function, = like: #+TBLFM: $6=3D'(coolfunc (time(...$5)-time(...$4))) If I would know how to pass the result, eg as a string, to a lisp = function I could sort it out, I guess. Thanks, Martin=