Created
June 10, 2015 08:40
-
-
Save lf94/10b46f5eb1d58712bd35 to your computer and use it in GitHub Desktop.
Calculate total hours for an Emacs timeclock log.
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
function toDateTime(date, time) { | |
gsub(/\//, " ", $2) | |
awkDate = $2 | |
gsub(/:/, " ", $3) | |
awkTime = $3 | |
return mktime(awkDate " " awkTime) | |
} | |
/^i / { | |
clockIn = toDateTime($2, $3) | |
} | |
/^o / { | |
clockOut = toDateTime($2, $3) | |
total += clockOut - clockIn; | |
} | |
END { print total/60.0/60.0 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment