function fmtSecs(secs, isPace) {
if (secs == null) {
return "---";
}
var s = secs.toLong();
var hours = 0;
if (!isPace) { // Performance boost: assumption: a pace value does never has hours!!
hours = s / 3600;
s -= hours * 3600;
}
var minutes = s / 60;
s -= minutes * 60;
var fmt;
if (hours != 0) {
fmt = "" + hours + ":" + minutes.format("%02d") + ":" + s.format("%02d");
} else {
fmt = "" + minutes + ":" + s.format("%02d");
}
return fmt;
}
The rounding bug is probably in these lines:
var minutes = s / 60;
s -= minutes * 60;
Is there a better implementation? What do you think?