| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 var timeutil = (function() { | 5 var timeutil = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Offset needed to convert event times to Date objects. | 9 * Offset needed to convert event times to Date objects. |
| 10 * Updated whenever constants are loaded. | 10 * Updated whenever constants are loaded. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * This function converts the tick count to a Date() object. | 25 * This function converts the tick count to a Date() object. |
| 26 * | 26 * |
| 27 * @param {String} timeTicks. | 27 * @param {String} timeTicks. |
| 28 * @returns {Date} The time that |timeTicks| represents. | 28 * @returns {Date} The time that |timeTicks| represents. |
| 29 */ | 29 */ |
| 30 function convertTimeTicksToDate(timeTicks) { | 30 function convertTimeTicksToDate(timeTicks) { |
| 31 var timeStampMs = timeTickOffset + (timeTicks - 0); | 31 var timeStampMs = timeTickOffset + (timeTicks - 0); |
| 32 return new Date(timeStampMs); | 32 return new Date(timeStampMs); |
| 33 } | 33 } |
| 34 | 34 |
| 35 /** |
| 36 * Returns the current time. |
| 37 * |
| 38 * @returns {number} Milliseconds since the Unix epoch. |
| 39 */ |
| 40 function getCurrentTime() { |
| 41 return (new Date()).getTime(); |
| 42 } |
| 43 |
| 35 return { | 44 return { |
| 36 setTimeTickOffset: setTimeTickOffset, | 45 setTimeTickOffset: setTimeTickOffset, |
| 37 convertTimeTicksToDate: convertTimeTicksToDate | 46 convertTimeTicksToDate: convertTimeTicksToDate, |
| 47 getCurrentTime: getCurrentTime |
| 38 }; | 48 }; |
| 39 })(); | 49 })(); |
| OLD | NEW |