Created
February 5, 2020 04:54
-
-
Save moshiurse/bbe8b0721df97e93ad883a160d8c1fd8 to your computer and use it in GitHub Desktop.
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 unitConverter(value, precession, lvl1, lvl2){ | |
var level1,level2,level3, rem, formatedUnit; | |
if(lvl1 && lvl1 > 0){ | |
level3 = value % lvl1; | |
rem = parseInt(value /lvl1); | |
formatedUnit = rem + "-"+ level3; | |
}else{ | |
if(precession){ | |
return value.toFixed(precession); | |
}else{ | |
return value; | |
} | |
} | |
if(lvl2 && lvl2 > 0){ | |
level2 = rem % lvl1; | |
level1 = parseInt(rem / lvl1); | |
formatedUnit = level1+ "-" + level2 + "-"+ level3; | |
} | |
return formatedUnit; | |
} | |
unitConverter(506,0, 0,12); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment