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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 } | 298 } |
299 | 299 |
300 /** | 300 /** |
301 * Return the current time as a formatted string suitable for logging. | 301 * Return the current time as a formatted string suitable for logging. |
302 * | 302 * |
303 * @return {string} The current time, formatted as [mmdd/hhmmss.xyz] | 303 * @return {string} The current time, formatted as [mmdd/hhmmss.xyz] |
304 */ | 304 */ |
305 remoting.timestamp = function() { | 305 remoting.timestamp = function() { |
306 /** | 306 /** |
307 * @param {number} num A number. | 307 * @param {number} num A number. |
308 * @param {number} len The required length of the answer. | |
308 * @return {string} The number, formatted as a string of the specified length. | 309 * @return {string} The number, formatted as a string of the specified length. |
Sergey Ulanov
2012/06/08 01:25:03
nit: maybe explain that this function does it by p
Jamie
2012/06/08 01:31:18
Done.
| |
309 */ | 310 */ |
310 var pad = function(num, len) { | 311 var pad = function(num, len) { |
311 var result = num.toString(); | 312 var result = num.toString(); |
312 if (result.length < len) { | 313 if (result.length < len) { |
313 result = new Array(len - result.length + 1).join('0') + result; | 314 result = new Array(len - result.length + 1).join('0') + result; |
314 } | 315 } |
315 return result; | 316 return result; |
316 }; | 317 }; |
317 var now = new Date(); | 318 var now = new Date(); |
318 var timestamp = pad(now.getMonth() + 1, 2) + pad(now.getDate(), 2) + '/' + | 319 var timestamp = pad(now.getMonth() + 1, 2) + pad(now.getDate(), 2) + '/' + |
319 pad(now.getHours(), 2) + pad(now.getMinutes(), 2) + | 320 pad(now.getHours(), 2) + pad(now.getMinutes(), 2) + |
320 pad(now.getSeconds(), 2) + '.' + pad(now.getMilliseconds(), 3); | 321 pad(now.getSeconds(), 2) + '.' + pad(now.getMilliseconds(), 3); |
321 return '[' + timestamp + ']'; | 322 return '[' + timestamp + ']'; |
322 }; | 323 }; |
OLD | NEW |