Chromium Code Reviews| Index: ui/webui/resources/js/util.js |
| diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js |
| index 56e2d2d283c0334f0dd4c6dd5f31bf0957deb38d..246d647628849e87fa88c8527a0ef13854e50a61 100644 |
| --- a/ui/webui/resources/js/util.js |
| +++ b/ui/webui/resources/js/util.js |
| @@ -424,3 +424,21 @@ function elide(original, maxLength) { |
| return original; |
| return original.substring(0, maxLength - 1) + '\u2026'; |
| } |
| + |
| + |
| +/** |
| + * Produces a readable HH hours MM min. SS sec. string representing |
| + * the amount of time provided as the number of seconds. |
| + * @param {number} totalSeconds The total amount of seconds. |
| + * @return {string} The formatted HH hours/hours MM min. SS sec. string |
| + */ |
| +function secondsToHMS(totalSeconds) |
| +{ |
| + totalSeconds = Number(totalSeconds); |
| + var hour = Math.floor(totalSeconds / 3600); |
| + var min = Math.floor(totalSeconds % 3600 / 60); |
| + var sec = Math.floor(totalSeconds % 3600 % 60); |
|
peria
2014/03/23 15:16:27
remove "% 3600"
|
| + return ((hour > 0 ? (hour + (hour > 1 ? ' hours ':' hour ')) : '') + |
| + (min > 0 ? (min + ' min. '): '' ) + |
| + (sec + ' sec. ')); |
| +} |