diff --git a/src/compiler/jsexecute.js b/src/compiler/jsexecute.js index 7e76ecaa..3314bd47 100644 --- a/src/compiler/jsexecute.js +++ b/src/compiler/jsexecute.js @@ -330,21 +330,14 @@ const timer = () => { return t; }; -// This is the "epoch" for the daysSince2000() function. -// Storing this in a variable is faster than constantly recreating it. -const daysSince2000Epoch = new Date(2000, 0, 1); - /** * Returns the amount of days since January 1st, 2000. * @returns {number} Days since 2000. */ -const daysSince2000 = () => { - const today = new Date(); - const dstAdjust = today.getTimezoneOffset() - daysSince2000Epoch.getTimezoneOffset(); - let mSecsSinceStart = today.valueOf() - daysSince2000Epoch.valueOf(); - mSecsSinceStart += ((today.getTimezoneOffset() - dstAdjust) * 60 * 1000); - return mSecsSinceStart / (24 * 60 * 60 * 1000); -}; +const daysSince2000 = () => + // Date.UTC(2000, 0, 1) === 946684800000 + // Hardcoding it is marginally faster + (Date.now() - 946684800000) / (24 * 60 * 60 * 1000); /** * Determine distance to a sprite or point.