/**
*
* DateX
* eXtended and localised Date parsing, diffing, formatting and validation for JavaScript, PHP, Python
* @version: 1.0.0
*
* https://github.com/foo123/DateX
*
**/
!function(t,e,n){"use strict";var r;"undefined"!=typeof Components&&"object"==typeof Components.classes&&"object"==typeof Components.classesByID&&Components.utils&&"function"==typeof Components.utils.import?(t.EXPORTED_SYMBOLS=[e],t[e]=n.call(t)):"object"==typeof module&&module.exports?module.exports=n.call(t):"function"==typeof define&&define.amd?define(e,["require","exports","module"],function(){return n.call(t)}):e in t||(t[e]=r=n.call(t))&&"function"==typeof define&&define.amd&&define(function(){return r})}("undefined"!=typeof self?self:this,"DateX",function(t){"use strict";var h=Object.prototype.hasOwnProperty,m=Math.floor,g=Math.ceil,y=Math.round,a=Math.abs,e=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,T=("undefined"!=typeof global&&"[object global]"===Object.prototype.toString.call(global)?global:window||this).Date,c={meridian:{am:"am",pm:"pm",AM:"AM",PM:"PM"},ordinal:{ord:{1:"st",2:"nd",3:"rd"},nth:"th"},timezone:["UTC","EST","MDT"],timezone_short:["UTC","EST","MDT"],day:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],day_short:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],month:["January","February","March","April","May","June","July","August","September","October","November","December"],month_short:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],units:{singular:{milliseconds:"millisecond",seconds:"second",minutes:"minute",hours:"hour",days:"day",weeks:"week",months:"month",years:"year"},plural:{milliseconds:"milliseconds",seconds:"seconds",minutes:"minutes",hours:"hours",days:"days",weeks:"weeks",months:"months",years:"years"}}},p=24,M=60,$=60,w=1e3,S=12,d=30.417,n=$*w,r=M*n,i=p*r,u=d*i,o=365.25*i,l={years:o,months:u,weeks:6048e5,days:i,hours:r,minutes:n,seconds:w,milliseconds:1,Y:o,M:u,W:6048e5,D:i,H:r,m:n,s:w,i:1},s={d:function(t,e){return h.call(e,"d")||(e.d="(31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01)"),e.d},D:function(t,e){return h.call(e,"D")||(e.D="("+Y(t.day_short.slice())+")"),e.D},l:function(t,e){return h.call(e,"l")||(e.l="("+Y(t.day.slice())+")"),e.l},j:function(t,e){return h.call(e,"j")||(e.j="(31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1)"),e.j},N:function(t,e){return h.call(e,"N")||(e.N="([1-7])"),e.N},S:function(t,e){if(!h.call(e,"S")){var n,r=t.ordinal.ord,a=[];for(n in r)h.call(r,n)&&a.push(r[n]);a.push(t.ordinal.nth),e.S="("+Y(a)+")"}return e.S},w:function(t,e){return h.call(e,"w")||(e.w="([0-6])"),e.w},z:function(t,e){return h.call(e,"z")||(e.z="([1-3]?[0-9]{1,2})"),e.z},W:function(t,e){return h.call(e,"W")||(e.W="([0-5]?[0-9])"),e.W},F:function(t,e){return h.call(e,"F")||(e.F="("+Y(t.month.slice())+")"),e.F},M:function(t,e){return h.call(e,"M")||(e.M="("+Y(t.month_short.slice())+")"),e.M},m:function(t,e){return h.call(e,"m")||(e.m="(12|11|10|09|08|07|06|05|04|03|02|01)"),e.m},n:function(t,e){return h.call(e,"n")||(e.n="(12|11|10|9|8|7|6|5|4|3|2|1)"),e.n},t:function(t,e){return h.call(e,"t")||(e.t="(31|30|29|28)"),e.t},L:function(t,e){return h.call(e,"L")||(e.L="([01])"),e.L},o:function(t,e){return h.call(e,"o")||(e.o="(\\d{2,4})"),e.o},Y:function(t,e){return h.call(e,"Y")||(e.Y="([12][0-9]{3})"),e.Y},y:function(t,e){return h.call(e,"y")||(e.y="([0-9]{2})"),e.y},a:function(t,e){return h.call(e,"a")||(e.a="("+Y([t.meridian.am,t.meridian.pm])+")"),e.a},A:function(t,e){return h.call(e,"A")||(e.A="("+Y([t.meridian.AM,t.meridian.PM])+")"),e.A},B:function(t,e){return h.call(e,"B")||(e.B="([0-9]{3})"),e.B},g:function(t,e){return h.call(e,"g")||(e.g="(12|11|10|9|8|7|6|5|4|3|2|1)"),e.g},G:function(t,e){return h.call(e,"G")||(e.G="(23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0)"),e.G},h:function(t,e){return h.call(e,"h")||(e.h="(12|11|10|09|08|07|06|05|04|03|02|01)"),e.h},H:function(t,e){return h.call(e,"H")||(e.H="(23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00)"),e.H},i:function(t,e){return h.call(e,"i")||(e.i="([0-5][0-9])"),e.i},s:function(t,e){return h.call(e,"s")||(e.s="([0-5][0-9])"),e.s},u:function(t,e){return h.call(e,"u")||(e.u="([0-9]{6})"),e.u},I:function(t,e){return h.call(e,"I")||(e.I="([01])"),e.I},O:function(t,e){return h.call(e,"O")||(e.O="([+-][0-9]{4})"),e.O},P:function(t,e){return h.call(e,"P")||(e.P="([+-][0-9]{2}:[0-5][0-9])"),e.P},Z:function(t,e){return h.call(e,"Z")||(e.Z="(-?[0-9]{5})"),e.Z},e:function(t,e){return h.call(e,"e")||(e.e="("+Y(t.timezone)+")"),e.e},T:function(t,e){return h.call(e,"T")||(e.T="("+Y(t.timezone_short)+")"),e.T},U:function(t,e){return h.call(e,"U")||(e.U="([0-9]{1,8})"),e.U},c:function(t,e){return h.call(e,"c")||(e.c=s.Y(t,e)+"-"+s.m(t,e)+"-"+s.d(t,e)+"\\\\"+s.T(t,e)+s.H(t,e)+":"+s.i(t,e)+":"+s.s(t,e)+s.P(t,e)),e.c},r:function(t,e){return h.call(e,"r")||(e.r=s.D(t,e)+",[ ]"+s.d(t,e)+"[ ]"+s.M(t,e)+"[ ]"+s.Y(t,e)+"[ ]"+s.H(t,e)+":"+s.i(t,e)+":"+s.s(t,e)+"[ ]"+s.O(t,e)),e.r}},f={d:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<1||31<t)&&((!h.call(n,"day")||t===n.day)&&void(n.day=t))},D:function(t,e,n){return!((t=e.day_short.indexOf(t))<0)&&((!h.call(n,"day_week")||t===n.day_week)&&void(n.day_week=t))},j:function(t,e,n){return!((t=parseInt(t,10))<1||31<t)&&((!h.call(n,"day")||t===n.day)&&void(n.day=t))},l:function(t,e,n){return!((t=e.day.indexOf(t))<0)&&((!h.call(n,"day_week")||t===n.day_week)&&void(n.day_week=t))},N:function(t,e,n){return!((t=parseInt(t,10))<1||7<t)&&(7===t&&(t=0),(!h.call(n,"day_week")||t===n.day_week)&&void(n.day_week=t))},S:null,w:function(t,e,n){return!((t=parseInt(t,10))<0||6<t)&&((!h.call(n,"day_week")||t===n.day_week)&&void(n.day_week=t))},z:function(t,e,n){return!((t=parseInt(t,10))<0||366<t)&&((!h.call(n,"day_year")||t===n.day_year)&&void(n.day_year=t))},W:function(t,e,n){return!((t=parseInt(t,10))<1||53<t)&&((!h.call(n,"week_year")||t===n.week_year)&&void(n.week_year=t))},F:function(t,e,n){return!((t=e.month.indexOf(t))<0)&&((!h.call(n,"month")||t+1===n.month)&&void(n.month=t+1))},m:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<1||12<t)&&((!h.call(n,"month")||t===n.month)&&void(n.month=t))},M:function(t,e,n){return!((t=e.month_short.indexOf(t))<0)&&((!h.call(n,"month")||t+1===n.month)&&void(n.month=t+1))},n:function(t,e,n){return!((t=parseInt(t,10))<1||12<t)&&((!h.call(n,"month")||t===n.month)&&void(n.month=t))},t:function(t,e,n){return!((t=parseInt(t,10))<28||31<t)&&((!h.call(n,"days_month")||t===n.days_month)&&void(n.days_month=t))},L:function(t,e,n){if("0"===t)n.leap=0;else{if("1"!==t)return!1;n.leap=1}},o:null,Y:function(t,e,n){return!((t=parseInt(t,10))<1e3||3e3<t)&&((!h.call(n,"year")||t===n.year)&&void(n.year=t))},y:function(t,e,n){return 2===t.length&&("00"<=t&&t<="69"?t="20"+t:"70"<=t&&t<="99"&&(t="19"+t)),!((t=parseInt(t,10))<1e3||3e3<t)&&((!h.call(n,"year")||t===n.year)&&void(n.year=t))},a:function(t,e,n){if(e.meridian.am===t)t="am";else{if(e.meridian.pm!==t)return!1;t="pm"}if(h.call(n,"meridian")&&t!==n.meridian)return!1;n.meridian=t},A:function(t,e,n){if(e.meridian.AM===t)t="am";else{if(e.meridian.PM!==t)return!1;t="pm"}if(h.call(n,"meridian")&&t!==n.meridian)return!1;n.meridian=t},B:null,g:function(t,e,n){return!((t=parseInt(t,10))<1||12<t)&&((!h.call(n,"hour_12")||t===n.hour_12)&&void(n.hour_12=t))},G:function(t,e,n){return!((t=parseInt(t,10))<0||23<t)&&((!h.call(n,"hour")||t===n.hour)&&void(n.hour=t))},h:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<1||12<t)&&((!h.call(n,"hour_12")||t===n.hour_12)&&void(n.hour_12=t))},H:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<0||23<t)&&((!h.call(n,"hour")||t===n.hour)&&void(n.hour=t))},i:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<0||59<t)&&((!h.call(n,"minute")||t===n.minute)&&void(n.minute=t))},s:function(t,e,n){return!((t=parseInt("0"===t.charAt(0)?t.slice(1):t,10))<0||59<t)&&((!h.call(n,"second")||t===n.second)&&void(n.second=t))},u:function(t,e,n){for(var r=0;1<t.length&&"0"===t.charAt(r);)r++;return!((t=~~((t=parseInt(t.slice(r),10))/1e3))<0||999<t)&&((!h.call(n,"ms")||t===n.ms)&&void(n.ms=t))},e:null,I:null,O:null,P:null,T:null,Z:null,U:function(t,e,n){return!((t=parseInt(t,10))<0)&&(t*=1e3,(!h.call(n,"time")||t===n.time)&&void(n.time=t))},c:null,r:null},D={G:function(t,e,n){return h.call(n,"G")||(n.G=t.getHours()),n.G},j:function(t,e,n){return h.call(n,"j")||(n.j=t.getDate(),n.jmod10=n.j%10),n.j},n:function(t,e,n){return h.call(n,"n")||(n.n=t.getMonth()+1),n.n},Y:function(t,e,n){return h.call(n,"Y")||(n.Y=t.getFullYear()),n.Y},w:function(t,e,n){return h.call(n,"w")||(n.w=t.getDay()),n.w},N:function(t,e,n){return h.call(n,"N")||(n.N=D.w(t,e,n)||7),n.N},d:function(t,e,n){return h.call(n,"d")||(n.d=C(D.j(t,e,n),2,"0")),n.d},D:function(t,e,n){return h.call(n,"D")||(n.D=e.day_short[D.w(t,e,n)]),n.D},l:function(t,e,n){return h.call(n,"l")||(n.l=e.day[D.w(t,e,n)]),n.l},S:function(t,e,n){var r;return h.call(n,"S")||(r=D.j(t,e,n),t=n.jmod10,n.S=e.ordinal.ord[r]?e.ordinal.ord[r]:e.ordinal.ord[t]?e.ordinal.ord[t]:e.ordinal.nth),n.S},z:function(t,e,n){var r,a;return h.call(n,"z")||(r=D.Y(t,e,n),a=D.n(t,e,n),e=D.j(t,e,n),n.z=y((new T(r,a-1,e)-new T(r,0,1))/864e5)),n.z},W:function(t,e,n){var r,a,i;return h.call(n,"W")||(r=D.Y(t,e,n),a=D.n(t,e,n),i=D.N(t,e,n),e=D.j(t,e,n),n.W=C(1+y((new T(r,a-1,e-i+3)-new T(r,0,4))/864e5/7),2,"0")),n.W},F:function(t,e,n){return h.call(n,"F")||(t=D.n(t,e,n),n.F=e.month[t-1]),n.F},m:function(t,e,n){return h.call(n,"m")||(e=D.n(t,e,n),n.m=C(e,2,"0")),n.m},M:function(t,e,n){return h.call(n,"M")||(t=D.n(t,e,n),n.M=e.month_short[t-1]),n.M},t:function(t,e,n){var r;return h.call(n,"t")||(r=D.n(t,e,n),e=D.Y(t,e,n),n.t=new T(e,r,0).getDate()),n.t},L:function(t,e,n){return h.call(n,"L")||(e=D.Y(t,e,n),n.L=e%4==0&e%100!=0|e%400==0),n.L},o:function(t,e,n){var r,a;return h.call(n,"o")||(r=D.Y(t,e,n),a=D.n(t,e,n),e=D.W(t,e,n),n.o=r+(12===a&&e<9?1:1===a&&9<e?-1:0)),n.o},y:function(t,e,n){return h.call(n,"y")||(e=D.Y(t,e,n),n.y=e.toString().slice(-2)),n.y},a:function(t,e,n){return h.call(n,"a")||(t=D.G(t,e,n),n.a=11<t?e.meridian.pm:e.meridian.am),n.a},A:function(t,e,n){return h.call(n,"A")||(t=D.G(t,e,n),n.A=11<t?e.meridian.PM:e.meridian.AM),n.A},B:function(t,e,n){return h.call(n,"B")||(n.B=C(m((3600*t.getUTCHours()+60*t.getUTCMinutes()+t.getUTCSeconds()+3600)/86.4)%1e3,3,"0")),n.B},g:function(t,e,n){return h.call(n,"g")||(e=D.G(t,e,n),n.g=e%12||12),n.g},h:function(t,e,n){return h.call(n,"h")||(e=D.g(t,e,n),n.h=C(e,2,"0")),n.h},H:function(t,e,n){return h.call(n,"H")||(e=D.G(t,e,n),n.H=C(e,2,"0")),n.H},i:function(t,e,n){return h.call(n,"i")||(n.i=C(t.getMinutes(),2,"0")),n.i},s:function(t,e,n){return h.call(n,"s")||(n.s=C(t.getSeconds(),2,"0")),n.s},u:function(t,e,n){return h.call(n,"u")||(n.u=C(1e3*t.getMilliseconds(),6,"0")),n.u},e:function(t,e,n){return""},I:function(t,e,n){return h.call(n,"I")||(e=D.Y(t,e,n),n.I=new T(e,0)-T.UTC(e,0)!=new T(e,6)-T.UTC(e,6)?1:0),n.I},O:function(t,e,n){var r;return h.call(n,"O")||(r=t.getTimezoneOffset(),t=a(r),n.O=(0<r?"-":"+")+C(100*m(t/60)+t%60,4,"0")),n.O},P:function(t,e,n){return h.call(n,"P")||(e=D.O(t,e,n),n.P=e.substr(0,3)+":"+e.substr(3,2)),n.P},T:function(t,e,n){return"UTC"},Z:function(t,e,n){return h.call(n,"Z")||(n.Z=60*-t.getTimezoneOffset()),n.Z},U:function(t,e,n){return h.call(n,"U")||(n.U=t/1e3|0),n.U},c:function(t,e,n){var r,a,i,u,o,l,c;return h.call(n,"c")||(r=D.Y(t,e,n),a=D.m(t,e,n),i=D.d(t,e,n),u=D.T(t,e,n),o=D.H(t,e,n),l=D.i(t,e,n),c=D.s(t,e,n),e=D.P(t,e,n),n.c=[r,"-",a,"-",i,"\\",u,o,":",l,":",c,e].join("")),n.c},r:function(t,e,n){var r,a,i,u,o,l,c;return h.call(n,"r")||(r=D.Y(t,e,n),a=D.M(t,e,n),i=D.D(t,e,n),u=D.d(t,e,n),o=D.H(t,e,n),l=D.i(t,e,n),c=D.s(t,e,n),e=D.O(t,e,n),n.r=[i,", ",u," ",a," ",r," ",o,":",l,":",c," ",e].join("")),n.r}},O=new RegExp("%("+["Ec","EC","Ex","EX","Ey","EY","Od","Oe","OH","OI","Om","OM","OS","Ou","OU","OV","Ow","OW","Oy","a","A","b","B","c","C","d","D","e","h","H","I","j","m","M","n","p","r","R","S","t","T","u","U","V","w","W","x","X","y","Y","Z","%"].join("|")+")","g"),F={"%":"%",a:"D",A:"l",b:"M",B:"F",c:"c",C:"",d:"d",D:"m/d/y",e:"j",h:"M",H:"H",I:"h",j:"z",m:"m",M:"i",n:"\n",p:"a",r:"r",R:"H:i",S:"s",t:"\t",T:"H:i:s",u:"N",U:"W",V:"W",w:"w",W:"W",y:"y",Y:"Y",Z:"T",Ey:"y",EY:"Y",Od:"d",Oe:"j",OH:"H",OI:"h",Om:"m",OM:"i",OS:"s",Ou:"N",OU:"W",OV:"W",Ow:"w",OW:"W",Oy:"y"};function U(t){return t.replace(e,"\\$&")}function v(t,e){return e.length-t.length}function Y(t){return t.sort(v).map(U).join("|")}function C(t,e,n){t=t.toString(),e-=t.length;return 0<e?new Array(1+e).join(n||" ")+t:t}function _(t,a){for(var e,n,i=function(t,e){e=e||c;for(var n,r="",a={},i=0,u=t.length;i<u;i++)n=t.charAt(i),r+=h.call(s,n)?s[n](e,a):" "===n?"[ ]":/\s/.test(n)?"\\s":U(n);return new RegExp("^"+r+"$","")}(t,a=a||c),r=0,u={},o=0,l=t.length;o<l;o++)if(e=t.charAt(o),h.call(f,e))if(f[e])if(f[e].push)for(n=0;n<f[e].length;n++)null==f[e][n]?++r:u[++r]=f[e][n];else u[++r]=f[e];else++r;return function(t){var e,n,r=t.match(i);if(!r)return!1;for(n={},e=1;e<r.length;e++)if(h.call(u,e)&&!1===u[e](r[e],a,n))return!1;return function(t,e){var n,r,a,i,u,o,l=0,c=[31,28,31,30,31,30,31,31,30,31,30,31],s=null,f=null,d=new T;e=e||{},h.call(t,"time")&&(f=new T(t.time),h.call(t,"year")||h.call(t,"month")||h.call(t,"day")||(s=new T(f)));if(null==s){if(o=h.call(t,"ms")?t.ms:h.call(e,"ms")?e.ms:0,u=h.call(t,"second")?t.second:h.call(e,"second")?e.second:0,i=h.call(t,"minute")?t.minute:h.call(e,"minute")?e.minute:0,a=h.call(t,"hour")?t.hour:h.call(t,"hour_12")?"pm"===t.meridian?11+t.hour_12:t.hour_12-1:h.call(e,"hour")?e.hour:"pm"===t.meridian?12:0,r=h.call(t,"day")?t.day:h.call(e,"day")?e.day:d.getDate(),n=h.call(t,"month")?t.month:h.call(e,"month")?e.month:d.getMonth()+1,d=h.call(t,"year")?t.year:h.call(e,"year")?e.year:d.getFullYear(),o<0||999<o)return!1;if(u<0||59<u)return!1;if(i<0||59<i)return!1;if(a<0||23<a)return!1;if(d<1||32767<d)return!1;if(l=d%4==0&d%100!=0|d%400==0,h.call(t,"leap")&&l!==t.leap)return!1;if(c[1]+=l,n<1||12<n)return!1;if(r<1||r>c[n-1])return!1;if(s=new T(d,n-1,r,a,i,u,o),h.call(t,"day_week")&&t.day_week!==s.getDay())return!1;if(h.call(t,"day_year")&&t.day_year!==y((new T(d,n-1,r)-new T(d,0,1))/864e5))return!1;if(h.call(t,"days_month")&&t.days_month!==c[n-1])return!1;if(h.call(t,"meridian")&&(11<a&&"am"===t.meridian||a<=11&&"pm"===t.meridian))return!1;if(null!=f&&s.getTime()!==f.getTime())return!1}return s}(n)}}function H(t,e,n){var r,a,i,u,o,l;if(t.substr)return t;for(null==t?o=new T:t instanceof T?o=new T(t):"number"==typeof t&&(o=new T(1e3*t)),n=n||c,r="",l={},i=0,u=e.length;i<u;i++)a=e.charAt(i),r+=h.call(D,a)?D[a](o,n,l):a;return r}function I(t){return t.replace(O,function(t,e){return h.call(F,e)?F[e]:t})}function j(t,e,n,r,a,i,u){var o=this,l=arguments.length;o.$date=l?t instanceof j?new T(t.$date):1===l?new T(t):new T(t,e,n||1,r||0,a||0,i||0,u||0):new T,o.$locale=j.defaultLocale,o.$format=j.defaultFormat}return f.c=[f.Y,f.m,f.d,null,f.H,f.i,f.s,null],f.r=[f.D,f.d,f.M,f.Y,f.H,f.i,f.s,null],j.VERSION="1.0.0",j.defaultLocale=c,j.defaultFormat="Y-m-d H:i:s",j.defaultDateFormat="Y-m-d",j.defaultTimeFormat="H:i:s",j.setDefaultLocale=function(t){t&&j.defaultLocale!==t&&(j.defaultParser=j.getParser(j.defaultFormat,j.defaultLocale=t))},j.setDefaultFormat=function(t,e,n){t&&j.defaultFormat!==t&&(j.defaultParser=j.getParser(j.defaultFormat=t,j.defaultLocale)),e&&j.defaultDateFormat!==e&&(j.defaultDateFormat=e),n&&j.defaultTimeFormat!==n&&(j.defaultTimeFormat=n)},j.resetDefaults=function(){j.defaultLocale=c,j.defaultFormat="Y-m-d H:i:s",j.defaultDateFormat="Y-m-d",j.defaultTimeFormat="H:i:s",j.defaultParser=j.getParser(j.defaultFormat,j.defaultLocale)},j.defaultParser=(j.getParser=function(t,e,n){return t&&!0===n&&(t=I(t)),_(t||j.defaultFormat,e||j.defaultLocale)})(j.defaultFormat,j.defaultLocale),j.parse=j.fromString=function(t,e,n,r){r=e&&j.defaultFormat!==e||n&&j.defaultLocale!==n?j.getParser(e,n,r):j.defaultParser,t=r(t);return!1!==t&&new j(t)},j.format=function(t,e,n,r){return e&&!0===r&&(e=I(e)),H(t instanceof j?t.$date:t,e||j.defaultFormat,n||j.defaultLocale)},j.now=T.now||function(){return(new T).getTime()},j.UTC=T.UTC,j.udiff=function(t,e,n){return n=(n=n||"days").toLowerCase(),e=t.getTime()-e.getTime(),n=a(e)/l[n],e<0?-n:n},j.xdiff=j.diffExact=function(t,e){var n,r={sign:1,years:0,months:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0};return e.getTime()>t.getTime()&&(r.sign=-1,n=e,e=t,t=n),r.years=t.getFullYear()-e.getFullYear(),r.months=t.getMonth()-e.getMonth(),r.days=t.getDate()-e.getDate(),r.hours=t.getHours()-e.getHours(),r.minutes=t.getMinutes()-e.getMinutes(),r.seconds=t.getSeconds()-e.getSeconds(),r.milliseconds=t.getMilliseconds()-e.getMilliseconds(),r},j.adiff=j.diffApproximate=function(t,e,n,r){for(var a,i,u,o,l=(a=e,u=1,o=[],e=(e=n)||1,(n=t).getTime()<a.getTime()&&(u=-1,i=a,a=n,n=i),(t=0)<(i=n.getFullYear()-a.getFullYear())&&o.push([i,"years"]),0<(i=n.getMonth()-a.getMonth())?o.push([i,"months"]):i<0&&(t=i*d),0<(i=n.getDate()-a.getDate()+t)?(o.push([y(i),"days"]),t=0):i<0&&(t=i*p),0<(i=n.getHours()-a.getHours()+t)?(o.push([y(i),"hours"]),t=0):i<0&&(t=i*M),0<(i=n.getMinutes()-a.getMinutes()+t)?(o.push([y(i),"minutes"]),t=0):i<0&&(t=i*$),0<(i=n.getSeconds()-a.getSeconds()+t)&&(o.push([y(i),"seconds"]),t=0),o.length||o.push[[0,"seconds"]],o.length>e&&(o.length=e),{rel:o,sign:u}),c=l.rel.length,s=(r||j.defaultLocale).units,f=0;f<c;f++)l.rel[f][1]=s[1===l.rel[f][0]?"singular":"plural"][l.rel[f][1]];return l},j.formatDiff=function(t){var e,n=t.rel.length,r="";if(1<n){for(r=t.rel[0][0]+" "+t.rel[0][1],e=1;e<n-1;e++)r+=", "+t.rel[e][0]+" "+t.rel[e][1];r+=" and "+t.rel[n-1][0]+" "+t.rel[n-1][1]}else r=t.rel[0][0]+" "+t.rel[0][1];return r+=t.sign<0?" ago":" later"},j.prettyDiff=function(t,e){var n,r="ago",a=(j.now()-t.getTime())/1e3;if(!isNaN(a)){var o,i=(o=e||{},function(t,e){var n=h.call(o,t)?o[t]:t;if(e&&e.length){for(var r,a=0,i=0,u="";-1<(r=n.indexOf("%s",a));)u+=n.slice(a,r)+e[i++],a=r+2;n=u+=n.slice(a)}return n});return a<0&&(a=-a,r="later"),n=m(a/86400),t=m(n/30.5),e=m(n/365.25),a<60?i("just now"):a<120?i("one minute "+r):a<3600?i("%s minutes "+r,[m(a/60)]):a<7200?i("one hour "+r):a<86400?i("%s hours "+r,[m(a/3600)]):1===n?i("ago"===r?"yesterday":"tomorrow"):n<7?i("%s days "+r,[n]):n<31?i("%s weeks "+r,[g(n/7)]):1===t?i("one month "+r):t<12?i("%s months "+r,[t]):1===e?i("one year "+r):i("%s years "+r,[e])}},j.uadd=function(t,e,n,r){return n=(n=n||"days").toLowerCase(),r=!0===r?t:new j(t),n=t.getTime()+e*l[n],r.setTime(n<0?0:n),r},j.xadd=j.addExact=function(t,e,n){var r,a=!0===n?t:new j(t),i=[31,28,31,30,31,30,31,31,30,31,30,31],u=(t.getTimezoneOffset(),h.call(e,"sign")&&e.sign<0?-1:1),o=t.getFullYear(),l=t.getMonth(),c=t.getDate(),s=t.getHours(),f=t.getMinutes(),d=t.getSeconds(),n=t.getMilliseconds();for(h.call(e,"years")&&(o+=u*e.years),h.call(e,"months")&&((l+=u*e.months)<0&&(o-=r=g(-l/S),l+=r*S),S<=l&&(o+=r=m(l/S),l-=r*S)),o<=0&&(o=1),t=o%4==0&o%100!=0|o%400==0,i[1]=28+t,c>i[l]&&(c=i[l]),h.call(e,"days")&&(c+=u*e.days),h.call(e,"milliseconds")&&((n+=u*e.milliseconds)<0&&(d-=r=g(-n/w),n+=r*w),w<=n&&(d+=r=g(n/w),n-=r*w)),h.call(e,"seconds")&&((d+=u*e.seconds)<0&&(f-=r=g(-d/$),d+=r*$),$<=d&&(f+=r=m(d/$),d-=r*$)),h.call(e,"minutes")&&((f+=u*e.minutes)<0&&(s-=r=g(-f/M),f+=r*M),M<=f&&(s+=r=m(f/M),f-=r*M)),h.call(e,"hours")&&((s+=u*e.hours)<0&&(c-=r=g(-s/p),s+=r*p),p<=s&&(c+=r=m(s/p),s-=r*p));c<=0||c>i[l];)c<=0?c+=i[--l]:c-=i[l++];return a.setDateObject(new T(o,l,c,s,f,d,n)),a},j.prototype={constructor:j,$date:null,$locale:null,$format:null,dispose:function(){return this.$date=null,this.$locale=null,this.$format=null,this},getDateObject:function(){return this.$date},setDateObject:function(t){return this.$date=t,this},getLocale:function(){return this.$locale},setLocale:function(t){return this.$locale=t,this},getFormat:function(){return this.$format},setFormat:function(t){return this.$format=t,this},format:function(t,e){return H(this.$date,t||this.$format,e||this.$locale)},strformat:function(t,e){return H(this.$date,I(t||this.$format),e||this.$locale)},udiff:function(t,e){return j.udiff(this,t,e)},xdiff:function(t){return j.xdiff(this,t)},adiff:function(t,e,n){return j.adiff(this,t,e,n||this.$locale)},prettydiff:function(t){return j.prettyDiff(this.$date,t||this.$locale)},uadd:function(t,e){return j.uadd(this,t,e,!0)},xadd:function(t){return j.xadd(this,t,!0)},getDate:function(){return this.$date.getDate()},getDay:function(){return this.$date.getDay()},getFullYear:function(){return this.$date.getFullYear()},getHours:function(){return this.$date.getHours()},getMilliseconds:function(){return this.$date.getMilliseconds()},getMinutes:function(){return this.$date.getMinutes()},getMonth:function(){return this.$date.getMonth()},getSeconds:function(){return this.$date.getSeconds()},getTime:function(){return this.$date.getTime()},getTimezoneOffset:function(){return this.$date.getTimezoneOffset()},getUTCDate:function(){return this.$date.getUTCDate()},getUTCDay:function(){return this.$date.getUTCDay()},getUTCFullYear:function(){return this.$date.getUTCFullYear()},getUTCHours:function(){return this.$date.getUTCHours()},getUTCMilliseconds:function(){return this.$date.getUTCMilliseconds()},getUTCMinutes:function(){return this.$date.getUTCMinutes()},getUTCMonth:function(){return this.$date.getUTCMonth()},getUTCSeconds:function(){return this.$date.getUTCSeconds()},getYear:function(){return this.$date.getYear()},setDate:function(t){return this.$date.setDate(t),this},setFullYear:function(t){return this.$date.setFullYear(t),this},setHours:function(t){return this.$date.setHours(t),this},setMilliseconds:function(t){return this.$date.setMilliseconds(t),this},setMinutes:function(t){return this.$date.setMinutes(t),this},setMonth:function(t){return this.$date.setMonth(t),this},setSeconds:function(t){return this.$date.setSeconds(t),this},setTime:function(t){return this.$date.setTime(t),this},setUTCDate:function(t){return this.$date.setUTCDate(t),this},setUTCFullYear:function(t){return this.$date.setUTCFullYear(t),this},setUTCHours:function(t){return this.$date.setUTCHours(t),this},setUTCMilliseconds:function(t){return this.$date.setUTCMilliseconds(t),this},setUTCMinutes:function(t){return this.$date.setUTCMinutes(t),this},setUTCMonth:function(t){return this.$date.setUTCMonth(t),this},setUTCSeconds:function(t){return this.$date.setUTCSeconds(t),this},setYear:function(t){return this.$date.setYear(t),this},toISOString:function(){return this.$date.toISOString()},toJSON:function(){return this.$date.toJSON()},toGMTString:function(){return this.$date.toGMTString()},toSource:function(){return this.$date.toSource()},valueOf:function(){return this.$date.valueOf()},toLocaleFormat:function(t){return this.format(t)},toDateString:function(t,e){return arguments.length?this.format(t||j.defaultDateFormat,e||this.$locale):this.$date.toDateString()},toTimeString:function(t,e){return arguments.length?this.format(t||j.defaultTimeFormat,e||this.$locale):this.$date.toTimeString()},toLocaleDateString:function(t){return arguments.length?this.format(t||j.defaultDateFormat,this.$locale):this.$date.toLocaleDateString()},toLocaleTimeString:function(t){return arguments.length?this.format(t||j.defaultTimeFormat,this.$locale):this.$date.toLocaleTimeString()},toLocaleString:function(t){return arguments.length?this.format(t||this.$format,this.$locale):this.$date.toLocaleString()},toUTCString:function(){return this.$date.toUTCString()},toString:function(t,e){return arguments.length?this.format(t||this.$format,e||this.$locale):this.$date.toString()}},j});
|