forked from science-ation/science-ation
Remove debug and properly pluralize hours/minutes/seconds
This commit is contained in:
parent
1a2fc19fca
commit
21ea57a661
@ -95,23 +95,28 @@ function format_duration(seconds) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var s=seconds;
|
var s=seconds;
|
||||||
var output=s+':';
|
var output='';
|
||||||
|
var pl='';
|
||||||
if(s>86400) {
|
if(s>86400) {
|
||||||
var days=Math.floor(s/86400)
|
var days=Math.floor(s/86400)
|
||||||
s-=days*86400;
|
s-=days*86400;
|
||||||
output+=days+' days ';
|
if(days>1) pl='s'; else pl='';
|
||||||
|
output+=days+' day'+pl+' ';
|
||||||
}
|
}
|
||||||
if(s>3600) {
|
if(s>3600) {
|
||||||
var hours=Math.floor(s/3600)
|
var hours=Math.floor(s/3600)
|
||||||
s-=hours*3600;
|
s-=hours*3600;
|
||||||
output+=hours+' hours ';
|
if(hours>1) pl='s'; else pl='';
|
||||||
|
output+=hours+' hour'+pl+' ';
|
||||||
}
|
}
|
||||||
if(s>60) {
|
if(s>60) {
|
||||||
var minutes=Math.floor(s/60)
|
var minutes=Math.floor(s/60)
|
||||||
s-=minutes*60;
|
s-=minutes*60;
|
||||||
output+=minutes+' minutes ';
|
if(minutes>1) pl='s'; else pl='';
|
||||||
|
output+=minutes+' minute'+pl+' ';
|
||||||
}
|
}
|
||||||
output+=s+' seconds ';
|
if(s>1) pl='s'; else pl='';
|
||||||
|
output+=s+' second'+pl;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user