Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 <include src="assert.js"> | 5 <include src="assert.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The global object. | 8 * The global object. |
| 9 * @type {!Object} | 9 * @type {!Object} |
| 10 * @const | 10 * @const |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 * @param {number} maxLength The maximum length allowed for the string. | 417 * @param {number} maxLength The maximum length allowed for the string. |
| 418 * @return {string} The original string if its length does not exceed | 418 * @return {string} The original string if its length does not exceed |
| 419 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' | 419 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' |
| 420 * appended. | 420 * appended. |
| 421 */ | 421 */ |
| 422 function elide(original, maxLength) { | 422 function elide(original, maxLength) { |
| 423 if (original.length <= maxLength) | 423 if (original.length <= maxLength) |
| 424 return original; | 424 return original; |
| 425 return original.substring(0, maxLength - 1) + '\u2026'; | 425 return original.substring(0, maxLength - 1) + '\u2026'; |
| 426 } | 426 } |
| 427 | |
| 428 | |
| 429 /** | |
| 430 * Produces a readable HH hours MM min. SS sec. string representing | |
| 431 * the amount of time provided as the number of seconds. | |
| 432 * @param {number} totalSeconds The total amount of seconds. | |
| 433 * @return {string} The formatted HH hours/hours MM min. SS sec. string | |
| 434 */ | |
| 435 function secondsToHMS(totalSeconds) | |
| 436 { | |
| 437 totalSeconds = Number(totalSeconds); | |
| 438 var hour = Math.floor(totalSeconds / 3600); | |
| 439 var min = Math.floor(totalSeconds % 3600 / 60); | |
| 440 var sec = Math.floor(totalSeconds % 3600 % 60); | |
|
peria
2014/03/23 15:16:27
remove "% 3600"
| |
| 441 return ((hour > 0 ? (hour + (hour > 1 ? ' hours ':' hour ')) : '') + | |
| 442 (min > 0 ? (min + ' min. '): '' ) + | |
| 443 (sec + ' sec. ')); | |
| 444 } | |
| OLD | NEW |