Skip to content

Instantly share code, notes, and snippets.

@daum
Created September 1, 2020 14:38
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 daum/72466781568ac8e257d41fcaacf92a90 to your computer and use it in GitHub Desktop.
Save daum/72466781568ac8e257d41fcaacf92a90 to your computer and use it in GitHub Desktop.
Clockify hours to decimals
var hourRegex = /([0-9]+):([0-9][0-9]):([0-9][0-9])/;
$("div").each(function(){
var matches =$(this).clone().children().remove().end().text().match(hourRegex);
if(matches && matches.length){
var decimal = parseInt(matches[1]);
decimal+= parseInt(matches[2])/60;
decimal+= parseInt(matches[3])/3600;
$(this).append("("+decimal.toFixed(2)+")");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment