Detect-It-Easy/db/duration
horsicq c140e3e3fe Fix
2020-09-07 00:40:53 +02:00

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";
}