Created
January 25, 2014 17:36
-
-
Save tomasos/8620223 to your computer and use it in GitHub Desktop.
calc hours worked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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