>> 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.. >> >> Thanks, >> Martin >> >> | 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='(hmconcat $8 $9)::$7=time(<2010-01-01 $5>)-time(<2010-01-01 >> $4>)+time(<2010-01-01 $3>)-time(<2010-01-01 $2>)::$8=hour($7)::$9=minute($7) >> >> (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))) > > Martin, > > glad to see you got further with this! > > 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): > > --8<---------------cut here---------------start------------->8--- > > | 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='(format "%02d:%02d" (string-to-number $8) (string-to-number > $9))::$7=time(<2010-01-01 $5>)-time(<2010-01-01 $4>)+time(<2010-01-01 > $3>)-time(<2010-01-01 $2>)::$8=hour($7)::$9=minute($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='(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