Skip to content

Commit

Permalink
added Date.now fallback to Common.now, closes #739
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Apr 9, 2021
1 parent 9915007 commit c06c107
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/Common.js
Expand Up @@ -252,9 +252,9 @@ module.exports = Common;

/**
* Returns the current timestamp since the time origin (e.g. from page load).
* The result will be high-resolution including decimal places if available.
* The result is in milliseconds and will use high-resolution timing if available.
* @method now
* @return {number} the current timestamp
* @return {number} the current timestamp in milliseconds
*/
Common.now = function() {
if (typeof window !== 'undefined' && window.performance) {
Expand All @@ -265,6 +265,10 @@ module.exports = Common;
}
}

if (Date.now) {
return Date.now();
}

return (new Date()) - Common._nowStartTime;
};

Expand Down

0 comments on commit c06c107

Please sign in to comment.