Skip to content

Instantly share code, notes, and snippets.

@lf94
Created June 10, 2015 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf94/10b46f5eb1d58712bd35 to your computer and use it in GitHub Desktop.
Save lf94/10b46f5eb1d58712bd35 to your computer and use it in GitHub Desktop.
Calculate total hours for an Emacs timeclock log.
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