Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date.js changes browser API for Date.now #136

Closed
mattpr opened this issue Apr 8, 2014 · 0 comments
Closed

date.js changes browser API for Date.now #136

mattpr opened this issue Apr 8, 2014 · 0 comments

Comments

@mattpr
Copy link

mattpr commented Apr 8, 2014

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

@pamval pamval closed this as completed Jun 9, 2014
buildguy pushed a commit that referenced this issue Jan 24, 2024
[BACKLOG-25221] Some initial work towards distributed builds that do …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants