0
\$\begingroup\$

I have the following org-table

datum werk start pauze start pauze stop werk stop
12/02/2024 09:48 12:45 13:14 17:22
13/02/2024 08:01 12:06 12:31 16:38
14/02/2024 07:38 12:12 12:38 16:48
15/02/2024 08:11 13:11 13:28 17:08

Now I want to calculate how many hours I did per day and see if I did too much or too little in a month.

For this I wrote some helper functions.

   (defun hm-to-minutes (str)
     (let* ((lst (split-string str ":"))
            (hour (car lst))
            (minute (cadr lst)))
       (+ (* (string-to-number hour) 60)
          (string-to-number minute))))

   (defun hm-get-minutes (str)
     (string-to-number (cadr (split-string str ":"))))

   (defun minutes-to-hm (minutes)
     (concat (format "%02d"  (/ minutes 60))
             ":"
             (format "%02d" (% minutes 60))))

  (defun hm-minutes-floor-quarter (str)
    (let* ((original (hm-to-minutes str))
          (minutes (hm-get-minutes str))
          (remainder (% minutes 15)))
      (- original remainder)))

   (defun hm-floor-quarter (str)
     (minutes-to-hm (hm-minutes-floor-quarter str)))

   (defun hm-ceil-quarter (str)
     (minutes-to-hm (+ (hm-minutes-floor-quarter str) 15)))

I also wrote some table functions, however I'm not happy with all the intermediate columns and the result on the last row in the columns I don't need.

datum werk start pauze start pauze stop werk stop werkelijk start werkelijk stop pauze te doen gepresteerd delta
12/02/2024 09:48 12:45 13:14 17:22 10:00 17:15 00:30 08:00 06:45 -01:15
13/02/2024 08:01 12:06 12:31 16:38 08:15 16:30 00:30 08:00 07:45 -00:15
14/02/2024 07:38 12:12 12:38 16:48 07:45 16:45 00:30 08:00 08:30 00:30
15/02/2024 08:11 13:11 13:28 17:08 08:15 17:00 00:30 08:00 08:15 00:15
#ERROR #ERROR 00:15 08:00 -00:15 -00:45
#+TBLFM: $6='(hm-ceil-quarter $2)
#+TBLFM: $7='(hm-floor-quarter $5)
#+TBLFM: $8=$4 - $3;U
#+TBLFM: $8='(hm-ceil-quarter $8)
#+TBLFM: $9=08:00;U
#+TBLFM: $10=($7 - $6 - $8);U
#+TBLFM: $11=($10 - $9);U::@>$11=vsum(@2..@-1);U

I'm most interested in columns gepresteerd and delta.

\$\endgroup\$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.