I have a need to convert microseconds to a human readable format. While I would be able convert it to HH:MM:SS.MS, I'm not sure the best way to strip the 00:'s if present I would like work with these
input = [ 12040000, 60042000, 15582000000 ]
output = [ '12.04', '1:00.42', '4:19:27' ]
function formatMark(mu) {
var timeList = []
var ms = mu / 1000
var time = new Date(ms)
var ms = time.getMilliseconds()
var ss = time.getSeconds()
var mm = time.getMinutes()
var hh = time.getHours()
if (ms > 1) timeList.push(ms) //
if (ss > 1) timeList.push(ss) //
if (mm > 1) timeList.push(mm) //
if (hh > 1) timeList.push(hh) //
return { hh + ':' + mm + ':' + ss + '.' + ms }
}
Unfortunately the code above doesn't work, probably for multiple reasons in which I'd be better off knowing, but I really just need a conventional and readable output. Any tips / suggestions are appreciated!