/** * (c) 2017 Avraham Ostreicher * HeDate.js is released under the MIT license */ !function(){function HeDate(){if(!(this instanceof HeDate))return(new HeDate).toString();var t=new Date;if(t.__proto__=this.__proto__,1==arguments.length)t.setTime(arguments[0]);else if(arguments.length>1){var e=l(arguments,[0,0,1,0,0,0,0]),r=e.slice(0,3),n=e.slice(3);t.setFullYear.apply(t,r),t.setHours.apply(t,n)}return t}var t=765433,e=25920,r=235,n=19,a=2092591,u="Invalid Date",i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["Tishri","Heshvan","Kislev","Tevet","Shevat","Adar I","Adar II","Nisan","Iyar","Sivan","Tamuz","Av","Elul","Adar"],l=function(t,e){for(var r=0,n=Math.min(t.length,e.length);n>r;)e[r]=t[r],r++;return e},s=function(t,e){return t-e*Math.floor(t/e)},h=function(t,e){if(!e){if(5==t)return o[13];t>5&&t++}return o[t]},f=function(t){return Math.floor(t/864e5)},v=function(t){return f(t.getTime()-6e4*t.getTimezoneOffset())},c=function(t){return f(t.getTime())},g=function(t){var e=S.apply(null,t);return Date.prototype.setFullYear.call(this,1970,0,e+1)},p=function(t){var e=S.apply(null,t);return Date.prototype.setUTCFullYear.call(this,1970,0,e+1)},T=function(t){var e=Y(t),r=(t+4)%7;r=i[r];var n=h(e.month,y(e.year-1)),a=("0"+e.date).slice(-2);return r+" "+a+" "+n+" "+e.year},d=function(t,e){var r=12+e;return N(t+r)},D=function(t,e){var r=e-t;return r%10-4},y=function(t){var e=s(t,n);return Boolean([2,5,7,10,13,16,18].indexOf(e)+1)},m=function(t){return Math.floor((t+38)*n/r)-3},M=function(t){return Math.ceil((t+3)*r/n)-38},C=function(r){var n,a,u;return n=r*e,a=n/t,a=Math.floor(a),u=m(a),a=M(u)},N=function(r){var n,a,u;return n=r*t+31524,u=a=Math.floor(s(n,181440)/e),n=s(n,e),n>=19440&&u++,[0,3,5,7].indexOf(u)+1&&u++,u==a&&(2==u&&n>=9924&&!y(m(r))?u+=2:1==u&&n>=16789&&y(m(r)-1)&&u++),Math.floor((r*t+31524)/e)+u-a},U=function(t,e,r){var n=y(e-1),a=y(r-1);return 5+n>t?0:a-n},Y=function(t){t+=a;var e,r=C(t),n=N(r);n>t&&(e=n,r=C(t-7),n=N(r)),t-=n;var u=m(r),i=y(u);e=e||d(r,i);var o=D(n,e,i);t>87?t-=o:t>58&&1==o&&(t-=.5),t>176&&(t-=.5*i);var l=Math.floor(t/29.5),s=Math.floor(t%29.5);return u++,s++,{year:u,month:l,date:s}},S=function(t,e,r){r--,t--;var n=M(t)+e;t=m(n),e=n-M(t),n-=e;var u=N(n),i=y(t),o=d(n,i),l=D(u,o,i);return u+=29.5*e,(e>1&&1==l||e>2)&&(u+=l),e>5&&(u+=.5*i),u=Math.ceil(u),u+=r,u-a};HeDate.prototype.__proto__=Date.prototype,Object.defineProperties(HeDate,{UTC:{value:function UTC(){var t=l(arguments,[NaN,NaN,1,0,0,0,0]),e=S.apply(null,t.slice(0,3));return t.splice(0,3,1970,0,e+1),Date.UTC.apply(null,t)}}}),Object.defineProperties(HeDate.prototype,{getFullYear:{value:function getFullYear(){var t=v(this);return Y(t).year}},getYear:{value:function getYear(){return this.getFullYear()}},getMonth:{value:function getMonth(){var t=v(this);return Y(t).month}},getDate:{value:function getDate(){var t=v(this);return Y(t).date}},getUTCFullYear:{value:function getUTCFullYear(){var t=c(this);return Y(t).year}},getUTCMonth:{value:function getUTCMonth(){var t=c(this);return Y(t).month}},getUTCDate:{value:function getUTCDate(){var t=c(this);return Y(t).date}},setFullYear:{value:function setFullYear(){var t=v(this),e=Y(t);e.month+=U(e.month,e.year,arguments[0]);var r=l(arguments,[NaN,e.month,e.date]);return g.call(this,r)}},setYear:{value:function setYear(){return this.setFullYear(arguments[0])}},setMonth:{value:function setMonth(){var t=v(this),e=Y(t),r=l(arguments,[NaN,e.date]);return r.splice(0,0,e.year),g.call(this,r)}},setDate:{value:function setDate(){var t=v(this),e=Y(t),r=[e.year,e.month,arguments[0]];return g.call(this,r)}},setUTCFullYear:{value:function setUTCFullYear(){var t=c(this),e=Y(t);e.month+=U(e.month,e.year,arguments[0]);var r=l(arguments,[NaN,e.month,e.date]);return p.call(this,r)}},setUTCMonth:{value:function setUTCMonth(){var t=c(this),e=Y(t),r=l(arguments,[NaN,e.date]);return r.splice(0,0,e.year),p.call(this,r)}},setUTCDate:{value:function setUTCDate(){var t=c(this),e=Y(t),r=[e.year,e.month,arguments[0]];return p.call(this,r)}},toDateString:{value:function toDateString(){if(isNaN(this))return u;var t=v(this);return T(t)}},toString:{value:function toString(){return isNaN(this)?u:this.toDateString()+" "+this.toTimeString()}},toUTCString:{value:function toUTCString(){if(isNaN(this))return u;var t=c(this);return T(t)}},toGMTString:{value:function toGMTString(){return this.toUTCString()}}}),"undefined"!=typeof window?window.HeDate=HeDate:"undefined"!=typeof module&&module.exports&&(module.exports=HeDate)}();