Created
September 1, 2020 14:38
-
-
Save daum/72466781568ac8e257d41fcaacf92a90 to your computer and use it in GitHub Desktop.
Clockify hours to decimals
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
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