I think it should be like this:
- function sformat(s) {
- var fm = [
- Math.floor(s / 60 / 60 / 24), // DAYS
- Math.floor(s / 60 / 60) % 24, // HOURS
- Math.floor(s / 60) % 60, // MINUTES
- s % 60 // SECONDS
- ];
- return $.map(fm, function(v, i) { return ((v < 10) ? '0' : '') + v; }).join(':');
- }
Your current implementation gives sformat(24 * 60 * 60) as 1:24:00:00.