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 | |
Bernhard Bauer
2014/03/25 16:36:10
Nit: This sentence reads a big bumpy. How about "[
| |
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 { | |
arv (Not doing code reviews)
2014/03/25 16:34:40
{ on previous line
Bernhard Bauer
2014/03/25 16:36:10
Opening braces goes on the previous line.
| |
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 % 60); | |
441 return ((hour > 0 ? (hour + (hour > 1 ? ' hours ':' hour ')) : '') + | |
arv (Not doing code reviews)
2014/03/25 16:34:40
Maybe use Intl.DateTimeFormat instead?
arv (Not doing code reviews)
2014/03/25 16:34:40
too many parentheses (the return expression is wra
Bernhard Bauer
2014/03/25 16:36:10
This is of course an i18n nightmare. But the page
arv (Not doing code reviews)
2014/03/25 16:38:15
I didn't even notice that this was in util.js
Ple
| |
442 (min > 0 ? (min + ' min. '): '' ) + | |
443 (sec + ' sec. ')); | |
444 } | |
OLD | NEW |