webdetails/cdf

date.js changes browser API for Date.now

Closed this issue · 0 comments

date.js (in daterangepicker.jQuery.js) overrides Date.now to be new Date() (type object) instead of current timestamp (type number).

This change of a browser's API breaks other modern javascript libraries that might be included on the page.

Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;}

This appears to be a patched version of date.js that doesn't have the issue...but I don't know who is updating or maintaining date.js.

http://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js

I went ahead and made the change. Pull request is here:

#135