1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

fix pluralization bug in formatter.timeInterval()

This commit is contained in:
Jordan Lee 2011-09-14 16:26:13 +00:00
parent 1abe7ce690
commit 9c2e8900a8

View file

@ -185,28 +185,31 @@ Transmission.fmt = (function()
timeInterval: function(seconds) timeInterval: function(seconds)
{ {
var result; var days = Math.floor (seconds / 86400),
var days = Math.floor(seconds / 86400); hours = Math.floor ((seconds % 86400) / 3600),
var hours = Math.floor((seconds % 86400) / 3600); minutes = Math.floor ((seconds % 3600) / 60),
var minutes = Math.floor((seconds % 3600) / 60); seconds = Math.floor (seconds % 60),
var seconds = Math.floor((seconds % 3600) % 60); d = days + ' ' + (days > 1 ? 'days' : 'day'),
h = hours + ' ' + (hours > 1 ? 'hours' : 'hour'),
m = minutes + ' ' + (minutes > 1 ? 'minutes' : 'minute'),
s = seconds + ' ' + (seconds > 1 ? 'seconds' : 'second');
if (days > 0 && hours === 0) if (days) {
result = [ days, 'days' ]; if (days >= 4 || !hours)
else if (days > 0 && hours > 0) return d;
result = [ days, 'days', hours, 'hr' ]; return d + ', ' + h;
else if (hours > 0 && minutes === 0) }
result = [ hours, 'hr' ]; if (hours) {
else if (hours > 0 && minutes > 0) if (hours >= 4 || !minutes)
result = [ hours,'hr', minutes, 'min' ]; return h;
else if (minutes > 0 && seconds === 0) return h + ', ' + m;
result = [ minutes, 'min' ]; }
else if (minutes > 0 && seconds > 0) if (minutes) {
result = [ minutes, 'min', seconds, 'seconds' ]; if (minutes >= 4 || !seconds)
else return m;
result = [ seconds, 'seconds' ]; return m + ', ' + s;
}
return result.join(' '); return s;
}, },
timestamp: function(seconds) timestamp: function(seconds)