Skip to content

Instantly share code, notes, and snippets.

@tomasos
Created January 25, 2014 17:36
Show Gist options
  • Save tomasos/8620223 to your computer and use it in GitHub Desktop.
Save tomasos/8620223 to your computer and use it in GitHub Desktop.
calc hours worked
;; calc hours worked
(defun time-to-decimal (time)
(+ (floor time) (/ (* 100 (- time (floor time))) 60)))
(defun calc-hours-worked ()
(interactive)
(setq line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(string-match "[0-9]\\{2\\}\.[0-9]\\{2\\}" line)
(setq start (string-to-number (match-string 0 line)))
(string-match "[0-9]\\{2\\}\.[0-9]\\{2\\}" line 5)
(setq end (string-to-number (match-string 0 line)))
(insert (format "\t%0.2f" (- (time-to-decimal end) (time-to-decimal start)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment