因此,在工作中我们使用flexitime(弹性小时,弹性小时......)这很好,但很难跟踪.我目前正在使用org-mode来跟踪我的小时数(org-clock-(out|in))但我想扩展它以自动计算我是否已经工作超过8小时(剩余时间应添加到我的弹性时间'帐户')或更少(取决于我休息的午休时间等),我的弹性时间'帐户'上的余额等等.
有没有其他人使用Emacs?
我目前正在使用一个非常基本的设置来跟踪我的时间:
(defun check-in ()
(interactive)
(let (pbuf (current-buffer))
(find-file (convert-standard-filename "whatnot"))
(goto-char (point-max))
(insert "\n")
(org-insert-heading)
(org-insert-time-stamp (current-time))
(org-clock-in)
(save-buffer)
(switch-to-buffer pbuf)))
(defun check-out ()
(interactive)
(let (pbuf (current-buffer))
(find-file (convert-standard-filename "whatnot"))
(goto-char (point-max))
(org-clock-out)
(save-buffer)
(switch-to-buffer pbuf)))
Run Code Online (Sandbox Code Playgroud)
假设我正确理解了你的问题,我就编写了一个快速解决方案。首先,如果您要多次签入和签出,则应确保每天仅创建一个大纲条目。定义以下函数来计算给定日期的加班时间。
(defun compute-overtime (duration-string)
"Computes overtime duration string for the given time DURATION-STRING."
(let (minutes-in-a-workday
work-minutes
overtime-minutes)
(defconst minutes-in-a-workday 480)
(setq work-minutes (org-duration-string-to-minutes duration-string)
overtime-minutes (- work-minutes minutes-in-a-workday))
(if (< overtime-minutes 0) (setq overtime-minutes 0))
(org-minutes-to-hh:mm-string overtime-minutes)))
Run Code Online (Sandbox Code Playgroud)
然后,在文件中的时钟表公式中使用它whatnot。
#+BEGIN: clocktable :maxlevel 1 :emphasize nil :scope file :formula "$3='(compute-overtime $2)::@2$3=string(\"Overtime\")"
#+END: clocktable
Run Code Online (Sandbox Code Playgroud)
C-c C-c当你在时钟表上时点击以重新生成它。
您可以通过使用另一个公式对加班时间求和来获得总加班时间。但是,我还没有解决这个问题。