Created
April 2, 2024 12:41
-
-
Save micheletolve/7b55311c04b654065673e61c56b06944 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
/** | |
* Convert value to the money. | |
* @param {any} s string with the value | |
* @param {number} ndd NumberDecimalDigits | |
* @returns | |
*/ | |
const toMoney = (s, ndd) => { | |
let cookieUser = GetLoggedUserInfo(); | |
let cookieCulture; | |
let culture; | |
if (cookieUser !== undefined) { | |
culture = cookieUser.LANGUAGE; | |
} else { | |
cookieCulture = GetCookie("culture"); | |
if (cookieCulture !== undefined) { | |
culture = cookieCulture; | |
} else { | |
culture = "en-US"; | |
} | |
} | |
let value = Number(parseFloat(s / 100)); | |
return value.toLocaleString(culture, { maximumFractionDigits: parseInt(ndd), minimumFractionDigits: parseInt(ndd) }); | |
} | |
/** | |
* Convert millisecond to time | |
* @param {any} m | |
* @returns | |
*/ | |
function millisecondsToTime(m) { | |
let milliseconds = m % 1000; | |
let seconds = Math.floor((m / 1000) % 60); | |
let minutes = Math.floor((m / (60 * 1000)) % 60); | |
return minutes + " min " + seconds + " sec " + milliseconds + " msec"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment