JSFiddle - React, Tailwind, and code Playground
by James Allardice
JavaScript
var NativeDate = window.NativeDate = Date,
args = new Array(NativeDate.length);
function replacement () {
var args = [].slice.call(arguments);
if (typeof args[0] === "string" && /^\d{4}\/\d{2}$/.test(args[0])) {
args[0] = args[0] + "/02";
}
args = [NativeDate.prototype].concat(args);
console.log(args);
return new (Function.prototype.bind.apply(NativeDate, args));
};
args.push("return (" + replacement + ").apply(null, [].slice.call(arguments));");
Date = new (Function.prototype.bind.apply(Function, [Function.prototype].concat(args)));
Object.getOwnPropertyNames(NativeDate).forEach(function (property) {
if (Object.getOwnPropertyNames(Function).indexOf(property) < 0) {
Date[property] = NativeDate[property];
}
});
console.log(Date.length);
console.dir(new Date("1992/02"));
console.log(Date.parse);