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