Changeset 12869
 Timestamp:
 Sep 14, 2011, 4:26:13 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/web/javascript/formatter.js
r12865 r12869 186 186 timeInterval: function(seconds) 187 187 { 188 var result; 189 var days = Math.floor(seconds / 86400); 190 var hours = Math.floor((seconds % 86400) / 3600); 191 var minutes = Math.floor((seconds % 3600) / 60); 192 var seconds = Math.floor((seconds % 3600) % 60); 193 194 if (days > 0 && hours === 0) 195 result = [ days, 'days' ]; 196 else if (days > 0 && hours > 0) 197 result = [ days, 'days', hours, 'hr' ]; 198 else if (hours > 0 && minutes === 0) 199 result = [ hours, 'hr' ]; 200 else if (hours > 0 && minutes > 0) 201 result = [ hours,'hr', minutes, 'min' ]; 202 else if (minutes > 0 && seconds === 0) 203 result = [ minutes, 'min' ]; 204 else if (minutes > 0 && seconds > 0) 205 result = [ minutes, 'min', seconds, 'seconds' ]; 206 else 207 result = [ seconds, 'seconds' ]; 208 209 return result.join(' '); 188 var days = Math.floor (seconds / 86400), 189 hours = Math.floor ((seconds % 86400) / 3600), 190 minutes = Math.floor ((seconds % 3600) / 60), 191 seconds = Math.floor (seconds % 60), 192 d = days + ' ' + (days > 1 ? 'days' : 'day'), 193 h = hours + ' ' + (hours > 1 ? 'hours' : 'hour'), 194 m = minutes + ' ' + (minutes > 1 ? 'minutes' : 'minute'), 195 s = seconds + ' ' + (seconds > 1 ? 'seconds' : 'second'); 196 197 if (days) { 198 if (days >= 4  !hours) 199 return d; 200 return d + ', ' + h; 201 } 202 if (hours) { 203 if (hours >= 4  !minutes) 204 return h; 205 return h + ', ' + m; 206 } 207 if (minutes) { 208 if (minutes >= 4  !seconds) 209 return m; 210 return m + ', ' + s; 211 } 212 return s; 210 213 }, 211 214
Note: See TracChangeset
for help on using the changeset viewer.