mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
16 lines
441 B
Text
16 lines
441 B
Text
// Convert a time in seconds to a string:
|
|
// less than 10 seconds: N.NNs
|
|
// less than a minute: NN.Ns
|
|
// otherwise: NmNNs
|
|
// Author: Jason Hood <jadoxa@yahoo.com.au>
|
|
|
|
function duration(nSeconds)
|
|
{
|
|
if(nSeconds<60)
|
|
{
|
|
return nSeconds.toFixed(nSeconds<10?2:1)+"s";
|
|
}
|
|
nSeconds=Math.round(nSeconds);
|
|
return Math.floor(nSeconds/60)+"m"
|
|
+("0"+Math.floor(nSeconds%60)).slice(-2)+"s";
|
|
}
|