Created
October 7, 2016 15:22
-
-
Save DanH42/11c1b6cffadf1c8ae2a9707661f2c476 to your computer and use it in GitHub Desktop.
Lies to other code on the page about the current date/time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date = function(Date){ | |
var fakeDate = 1475852400000; // Fri Oct 07 2016 10:00:00 GMT-0500 (CDT) | |
var bind = Function.bind; | |
var unbind = bind.bind(bind); | |
function NewDate(){ | |
if(arguments.length === 0) | |
arguments = [fakeDate]; | |
return new (unbind(Date, null).apply(null, arguments)); | |
} | |
NewDate.prototype = Date.prototype; | |
var names = Object.getOwnPropertyNames(Date); | |
for(var i = 0; i < names.length; i++){ | |
if(names[i] in NewDate) continue; | |
var desc = Object.getOwnPropertyDescriptor(Date, names[i]); | |
Object.defineProperty(NewDate, names[i], desc); | |
} | |
return NewDate; | |
}(Date); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment