Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Off-by-1 month when coercing a date if the coerced month has fewer da…

…ys than the current month
  • Loading branch information...
commit 4d48b6f18a88452ee34ce9da0c5712b1bac010a7 1 parent 333d33d
@Aldaviva Aldaviva authored
Showing with 3 additions and 3 deletions.
  1. +1 −1  d8.js
  2. +1 −1  d8.min.js
  3. +1 −1  src/coerce.js
View
2  d8.js
@@ -155,7 +155,7 @@
if ( isNaN( parsers[DAY] ) ) parsers[DAY] = 1;
- date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] ); date.setDate( parsers[DAY] );
+ date.setDate( parsers[DAY] ); date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] );
}
function parse_setTime( date, hr, min, sec, ms ) {
View
2  d8.min.js
@@ -1 +1 @@
-!function(e){"use strict";e.x.cache("Date",function(t){function n(e,t){var n=e.indexOf(t);return-1==n?null:n}function r(e){return e.toLocaleLowerCase()}function i(e){return e.toLocaleUpperCase()}function u(e,t){return e.reduce(function(e,n,r){return e[t[r]]=n,e},{})}function s(e,t,n){return e>=t&&n>=e}function a(e,t,n){var r=-1,i=e.toString(n||10);for(t-=i.length;++r<t;)i="0"+i;return i}function o(e,t){return e+t}function c(e,t){return l(t)(e)}function l(n){var r,i,s,a,o,c,l,h=t.locale.id;if(At[h][n])return At[h][n];for(c=n.replace(Zt,Lt).replace(Wt,Ft).split(Vt),i=[],r=-1,s=c.length,a={},l=[];++r<s;)o=c[r],o!=Tt?o.replace(ct,function(t,n,r,s){var o,c,f;(f=ot[r])&&(f.k&&(i.push(f.k),f.fn&&(a[f.k]=f.fn)),f.combo&&(c=f.combo.pluck("k"),o=u(f.combo.pluck("fn"),c),i.push.apply(i,c),e.copy(a,o,!0)),f.re&&l.push(n,f.re,s))}):(l.push(c[++r]),++r);return At[h][n]=f.bind(null,new RegExp(l.join("")),i,a)}function f(e,n,r,i){var s=new t,a=i.match(e),o=u(a.slice(1),n);return Object.reduce(o,function(e,t,n){return"string"==typeof t&&r[n]&&(o[n]=r[n](t,o)),e},null),isNaN(o[Dt])?(g(s,o[vt],o[Nt],o[Yt],o[wt]),h(s,o),m(s,o[jt])):s.setTime(o[Dt]),s}function h(n,r){var i,u,a,o,c=t.locale,l=-1;if(!Ct.every(e.has.bind(null,r))){if(isNaN(r[xt])&&(r[xt]=n.getFullYear()),isNaN(r[Ot])&&(a=c.isLeapYear(r[xt])?1:0,o=c.ordinal_day_count[a],u=o.length,r[Ot]=0,r[St]&&!r[yt]&&(i=r[Mt],i=isNaN(i)?0:i?i:7,r[yt]=r[St]*7-(4-i)),!isNaN(r[yt])))for(r[yt]>o[o.length-1]&&(r[yt]-=o[o.length-1],++r[xt]);++l<u;)if(s(r[yt],o[l],o[l+1])){r[Ot]=l,r[kt]=o[l]==0?r[yt]:r[yt]-o[l];break}isNaN(r[kt])&&(r[kt]=1),n.setYear(r[xt]),n.setMonth(r[Ot]),n.setDate(r[kt])}}function g(e,t,n,r,i){e.setHours(t||0),e.setMinutes(n||0),e.setSeconds(r||0),e.setMilliseconds(i||0)}function m(e,n){!s(n,-43200,50400)||e.adjust(t.SECOND,-e.getTimezoneOffset()*60-n)}function d(n,r){switch(e.ntype(n)){case"number":case"string":if(!q(new t(n))){r||(r=n),n=t.now();break}n=new t(n);case"array":case"object":r=n,n=t.now();break;case"date":if(q(new t(+n)))break;default:n=t.now()}var i,u=+n-+this,s=0>u?1:u>0?-1:0;return s?i=b(Math.abs(u),_(r)):(i=e.obj(),i.value=0),i.tense=s,i}function p(e,t,n,r){var i;return e.__ms__?e.excl[t[0]]?r[n+1]&&!e.excl[r[n+1][0]]||!(t=r[n-1])?e:(i=e.__ms__/t[1],e.__ms__=Math.round(i)*t[1]+e.__ms__/r[n][1]%1*r[n][1],p(e,t,n-1,[])):(e.__ms__>=t[1]&&(i=e.__ms__/t[1],t[0]in e.val?(i=Math.floor(i),e.__ms__-=i*t[1],e.val[t[0]]+=i):(e.__ms__=i%1*t[1],e.val[t[0]]=Math.floor(i))),e):e}function b(t,n){var r=Qt.reduce(p,{__ms__:t,excl:n,val:e.obj()}).val;return r.value=t,r}function _(t){var n=e.obj(),r=!0;if(t)switch(e.ntype(t)){case"object":r=!1;break;case"string":t=t.split(" ");case"array":t=t.reduce(k,n),r=!!e.len(n)}return Xt.map(function(e){e in this||(this[e]=!r)},n),n}function k(e,t){var n=(t=String(t).toLowerCase()).substring(1);switch(t.charAt(0)){case"-":e[n]=!0;break;case"+":e[n]=!1;break;case">":Qt.map(M,{excl:e,prop:n,val:!0});break;case"<":Qt.slice().reverse().map(M,{excl:e,prop:n,val:!1});break;default:e[t]=!1}return e}function M(e){e[0]===this.prop&&(this.SET_VALID=!0),this.SET_VALID&&(this.excl[e[0]]=this.val)}function y(t){return t=e.copy(t),e.remove(t,"tense","value"),Object.keys(t).map(function(e){return[Xt.indexOf(e),e]}).sort(function(e,t){return e=e[0],t=t[0],e>t?1:-1}).pluck(1)}function v(e,n){return(e=Number(e))<12&&r(n.ampm)==r(t.locale.PM)?e+=12:e}function w(e,t,n){return e.adjust(n,t)}function N(t){return Et.reduce(function(e,n,r){var i=parseFloat(t[r]);return isNaN(i)||0===i||(e[n]=i),e},e.obj())}function O(e){return Math.floor((e-C.call(e))/ft)}function Y(e){"Z"==e&&(e="0000");var t=!!e.indexOf("-"),n=e.match(Jt),r=(Number(n[1])+n[2]/60)*3600;return t?r:-r}function j(e){return Math.floor(Math.abs(O(e)/7))}function D(e,t){return isNaN(t)?Number(e)-1:t==e?0:Number(t)}function S(n,r){var i,u,s,a=this;switch(e.ntype(n)){case"number":n=arguments;case"array":n=N(n);case"object":Object.reduce(n,w,a);break;case"string":u=Ht[n.toLowerCase()],u&&0!==r&&(t.locale.setLeapYear(a),u==Ht.month&&(i=a.getDate(),28>i||a.setDate(Math.min(i,U.call(H.call(a).adjust(t.MONTH,r)).getDate()))),u!=Ht.week||(s=a.getDay()),a[u[1]](a[u[0]]()+r),!s||a.setDate(a.getDate()+s))}return a}function x(e,t){return+this>=+e&&+t>=+this}function T(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this}function L(){return new t(this.getTime())}function F(){var e=t.locale;return e.setLeapYear(this),e.day_count.slice(0,this.getMonth()).reduce(o,0)+this.getDate()-1}function H(){return new t(this.getFullYear(),this.getMonth(),1)}function E(e){var t=this.getTimezoneOffset();return[t>0?"-":"+",a(Math.floor(Math.abs(t)/60),2),e?":":"",a(Math.abs(t%60),2)].join("")}function I(){return this.getDay()||7}function A(){return Math.ceil((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/ft)}function C(){var e=this.getFullYear();return new t(e,0,lt[new t(e,0,1).getDay()])}function z(){var e,n=this.getFullYear();return this>=C.call(new t(n+1,0,1))?1:(e=Math.floor((F.call(this)-I.call(this)+10)/7),0==e?R.call(new t(n-1,0,1))-j(this):e)}function R(){return Math.round((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/pt)}function U(){var e=t.locale,n=this.getMonth();return e.setLeapYear(this),new t(this.getFullYear(),n,e.day_count[n])}function W(){return Math.floor(F.call(this)/7)}function Z(){return new t(this.getFullYear(),0,1).getTimezoneOffset()!=this.getTimezoneOffset()}function P(){return t.locale.isLeapYear(this.getFullYear())}function G(e){return this.setMonth(0),this.setDate(1),this.adjust(t.DAY,7*e).getTime()}function K(){var e=this.toString().split(" ");return e.splice(4,e.length).join(" ").replace($t,"$1").replace(Bt,"")}function q(t){return e.ntype(t)=="date"&&!isNaN(+t)}function V(e){var n,r,i,u,s,a,o=t.locale.id;if(It[o][e])return It[o][e];for(n=[" var out=[];"],s=e.replace(Zt,Lt).replace(Wt,Ft).split(Vt),a=/^[^A-Za-z]*$/g,r=-1,i=s.length;++r<i;)u=s[r],u==Tt?(n.push(J(s[++r])),++r):a.test(u)?n.push(J(u)):n.push(B(u));return n.push('return out.join( "" );\n //@ sourceURL=d8/format/'+o+"/"+e),It[o][e]=new Function("filter","date",n.join("\n\n "))}function $(e){return V(e)(ut,this)}function B(e){return e.replace(ct,function(e,t,n,r){return J(t+"', filter."+n+"( date ), '"+r)})}function J(e){return"out.push( '"+e+"' );"}function Q(e,n){q(e)||(q(new t(e))?e=new t(e):(n=e,e=t.now()));var r=t.locale.lexicon;return typeof zt[n=String(n).toLowerCase()]!="function"&&(n=r.DEFAULT),+e-+this?zt[n].call(r,this,e).replace(qt," "):r.just_now}function X(e){return e.join(" ")}function et(e,t){var n=e.pop();return(e.length?e.join(this.delim)+" "+this.and+" "+n:n)+" "+this[t.tense<1?"ago":"from_now"]}function tt(n){switch(e.ntype(n)){case"object":if(n.id){Rt[n.id]=n;break}case"string":if(n in Rt){n=Rt[n];break}default:n=null}return e.ntype(n)=="object"&&(e.defs(t,{locale:{value:n},getOrdinal:n.getOrdinal,isLeapYear:n.isLeapYear,setLeapYear:n.setLeapYear},"w",!0),n.id in It||(It[n.id]=e.obj()),n.id in At||(At[n.id]=e.obj()),ut=nt(n),at=rt(n),ot=it(n)),t}function nt(n){var u={d:function(e){return a(e.getDate(),2)},D:function(e){return n.days[e.getDay()].substring(0,3)},j:function(e){return e.getDate()},l:function(e){return n.days[e.getDay()]},N:function(e){return I.call(e)},S:function(e){return n.getOrdinal(e.getDate())},w:function(e){return e.getDay()},z:function(e){return e.getDayOfYear()},W:function(e){return z.call(e)},F:function(e){return n.months[e.getMonth()]},m:function(e){return a(e.getMonth()+1,2)},M:function(e){return n.months[e.getMonth()].substring(0,3)},n:function(e){return e.getMonth()+1},t:function(e){return n.setLeapYear(e),n.day_count[e.getMonth()]},L:function(e){return e.isLeapYear()?1:0},o:function(e){var t=e.getMonth(),n=z.call(e);return e.getFullYear()+(1==n&&t>0?1:n>=52&&11>t?-1:0)},Y:function(e){return e.getFullYear()},y:function(e){return String(e.getFullYear()).substring(2,4)},a:function(e){return r(e.getHours()<12?n.AM:n.PM)},A:function(e){return i(e.getHours()<12?n.AM:n.PM)},g:function(e){return e.getHours()%12||12},G:function(e){return e.getHours()},h:function(e){return a(ut.g(e),2)},H:function(e){return a(ut.G(e),2)},i:function(e){return a(e.getMinutes(),2)},s:function(e){return a(e.getSeconds(),2)},u:function(e){return a(e.getMilliseconds(),3)},O:function(e){return E.call(e)},P:function(e){return E.call(e,!0)},T:function(e){return K.call(e)},Z:function(e){return e.getTimezoneOffset()*-60},c:function(e){return $.call(e,at.ISO_8601)},r:function(e){return $.call(e,at.RFC_2822)},U:function(e){return e.getTime()},e:function(e){return e.lexicalize("exact")},x:function(e){return e.lexicalize("approx")}};return st=Object.keys(u).sort().join(""),ct=new RegExp("([^"+st+"]*)(["+st+"])([^"+st+"]*)","g"),e.def(t,"filters",{value:ut=u},"w",!0),u}function rt(n){var r=e.copy({ISO_8601:"Y-m-d<T>H:i:s.u<Z>",ISO_8601_SHORT:"Y-m-d",RFC_850:"l, d-M-y H:i:s T",RFC_2822:"D, d M Y H:i:s O",sortable:"Y-m-d H:i:sO"},n.formats);return r.atom=r.ISO_8601,r.cookie=r.RFC_850,r.rss=r.RFC_2822,e.def(t,"formats",{value:at=r},"w",!0),r}function it(u){var s={d:{k:kt,fn:Number,re:Gt},D:{k:Mt,fn:n.bind(null,u.days_short),re:"("+u.days_short.join("|")+")"},j:{k:kt,fn:Number,re:Pt},l:{k:Mt,fn:n.bind(null,u.days),re:"("+u.days.join("|")+")"},N:{k:Mt,fn:D.bind(null,7),re:"([1-7])"},S:{re:"(?:"+u.ordinal.join("|")+")"},w:{k:Mt,fn:Number,re:"([0-6])"},z:{k:yt,fn:Number,re:"([0-9]{1,3})"},W:{k:St,fn:Number,re:Gt},F:{k:Ot,fn:n.bind(null,u.months),re:"("+u.months.join("|")+")"},m:{k:Ot,fn:D,re:Gt},M:{k:Ot,fn:n.bind(null,u.months_short),re:"("+u.months_short.join("|")+")"},n:{k:Ot,fn:D,re:Pt},t:{re:"[0-9]{2}"},L:{re:"(?:0|1)"},o:{k:xt,fn:Number,re:Kt},Y:{k:xt,fn:Number,re:Kt},y:{k:xt,fn:function(e){return e=Number(e),e+=30>e?2e3:1900},re:Gt},a:{k:_t,fn:e,re:Ut},A:{k:_t,fn:r,re:i(Ut)},g:{k:vt,fn:v,re:Pt},G:{k:vt,fn:Number,re:Pt},h:{k:vt,fn:v,re:Gt},H:{k:vt,fn:Number,re:Gt},i:{k:Nt,fn:Number,re:Gt},s:{k:Yt,fn:Number,re:Gt},u:{k:wt,fn:Number,re:"([0-9]{1,})"},O:{k:jt,fn:Y,re:"([\\+-][0-9]{4})"},P:{k:jt,fn:Y,re:"([\\+-][0-9]{2}:[0-9]{2})"},T:{re:"[A-Z]{1,4}"},Z:{k:jt,fn:Y,re:"(Z|[\\+-]?[0-9]{2}:?[0-9]{2})"},U:{k:Dt,fn:Number,re:"(-?[0-9]{1,})"}};return s.c={combo:[s.Y,s.m,s.d,s.H,s.i,s.s,s.u,s.P],re:[s.Y.re,"-",s.m.re,"-",s.d.re,"T",s.H.re,":",s.i.re,":",s.s.re,"(?:\\.",s.u.re,"){0,1}",s.Z.re,"{0,1}"].join("")},s.r={combo:[s.D,s.d,s.M,s.Y,s.H,s.i,s.s,s.O],re:[s.D.re,", ",s.d.re," ",s.M.re," ",s.Y.re," ",s.H.re,":",s.i.re,":",s.s.re," ",s.O.re].join("")},e.def(t,"parsers",{value:ot=s},"w",!0),s}var ut,st,at,ot,ct,lt=[9,1,0,-1,-2,4,3],ft=864e5,ht=36e5,gt=6e4,mt=2592e6,dt=1e3,pt=6048e5,bt=31536e6,_t="ampm",kt="day",Mt="dayweek",yt="dayyear",vt="hour",wt="ms",Nt="minute",Ot="month",Yt="second",jt="timezone",Dt="unix",St="week",xt="year",Tt="NOREPLACE",Lt="<"+Tt+"<",Ft=">END"+Tt+">",Ht={day:["getDate","setDate"],hr:["getHours","setHours"],min:["getMinutes","setMinutes"],month:["getMonth","setMonth"],ms:["getMilliseconds","setMilliseconds"],sec:["getSeconds","setSeconds"],week:["getWeek","setWeek"],year:["getFullYear","setFullYear"]},Et=[xt,Ot,St,kt,"hr",Nt.substring(0,3),Yt.substring(0,3),wt],It=e.obj(),At=e.obj(),Ct=[kt,Mt,yt,Ot,St,xt],zt=e.obj(),Rt=e.obj(),Ut="(am|pm)",Wt=/>/g,Zt=/</g,Pt="([0-9]{1,2})",Gt="([0-9]{2})",Kt="([0-9]{4})",qt=/\s{2,}/g,Vt=/[<>]/,$t=/[^\(]*\(([^\)]+)\)/g,Bt=/[^A-Z]+/g,Jt=/[\+-]?([0-9]{2}):?([0-9]{2})/,Qt=[[xt+"s",bt],[Ot+"s",mt],[St+"s",pt],[kt+"s",ft],[vt+"s",ht],[Nt+"s",gt],[Yt+"s",dt],[wt,1]],Xt=Qt.pluck(0);zt.approx=function(e,n){var r,i,u,s,a,o,c,l=this.a,f=e.diff(n),h=t.diffKeys(f),g=t.time_map,m=this.time_units;if(f.value<t.MS_MINUTE)return this.just_now;switch(h[0]){case"years":u=0;break;case"months":u=1;break;case"weeks":u=2;break;case"days":f.days<2&&(o=e.format("l")===n.format("l"),c=o||h[1]!="hours"||f.hours<25),u=3;break;case"hours":o=e.format("l")===n.format("l"),c=f.hours/24>=.75,l=this.an,u=4;break;case"minutes":u=5}if(i=(f.value-g[u][1]*f[h[0]])/g[u][1],c)return o?this.today:f.tense>0?this.tomorrow:this.yesterday;if(s=[],a=f.tense>0?this.from_now:this.ago,.1>i)switch(h[0]){case"years":case"months":case"weeks":if(f[h[0]]===1){s.push(f.tense<1?this.last:this.next,m[u][0]);break}default:!i||s.push(this.about),s.push(f[h[0]],m[u][f[h[0]]>1?1:0],a)}else.74>i?.24>i?r=this.just_over:(r=i>.24&&.4>i?this.almost:this.about,s.push(this.and,this.a,this.half)):s.push(this.almost,f[h[0]]+1,m[u][1],a);return r&&(s.push(m[u][f[h[0]]>1||s.length?1:0],a),s.unshift(r,f[h[0]])),typeof this.approx=="function"?this.approx.call(this,s,f):X.call(this,s,f)},zt.exact=function(e,n){var r,i=e.diff(n),u=this.time_units;return r=t.time_map.reduce(function(e,t,n){var r=i[t[0]];return!r||!u[n]||e.push(r+" "+u[n][r>1?1:0]),e},[]),r.length?typeof this.exact=="function"?this.exact.call(this,r,i):et.call(this,r,i):this.just_now},e.defs(t.prototype,{adjust:S,between:x,clearTime:T,clone:L,diff:d,format:$,getDayOfYear:F,getFirstOfTheMonth:H,getGMTOffset:E,getISODay:I,getISODaysInYear:A,getISOFirstMondayOfYear:C,getISOWeek:z,getISOWeeksInYear:R,getLastOfTheMonth:U,getWeek:W,isDST:Z,isLeapYear:P,lexicalize:Q,setWeek:G,timezone:K,valid:function(){return t.valid(this)}},"r"),e.defs(t,{DAY:kt,HOUR:"hr",MINUTE:Nt.substring(0,3),MILLISECOND:wt,MONTH:Ot,SECOND:Yt.substring(0,3),WEEK:St,YEAR:xt,MS_DAY:ft,MS_HOUR:ht,MS_MINUTE:gt,MS_MONTH:mt,MS_SECOND:dt,MS_WEEK:pt,MS_YEAR:bt,lexicon:{value:zt},time_map:{value:Qt},time_props:{value:Xt},coerce:c,diffKeys:y,localize:tt,toDate:c,valid:q},"r")}).x(Date)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null);
+!function(e){"use strict";e.x.cache("Date",function(t){function n(e,t){var n=e.indexOf(t);return-1==n?null:n}function r(e){return e.toLocaleLowerCase()}function i(e){return e.toLocaleUpperCase()}function u(e,t){return e.reduce(function(e,n,r){return e[t[r]]=n,e},{})}function s(e,t,n){return e>=t&&n>=e}function a(e,t,n){var r=-1,i=e.toString(n||10);for(t-=i.length;++r<t;)i="0"+i;return i}function o(e,t){return e+t}function c(e,t){return l(t)(e)}function l(n){var r,i,s,a,o,c,l,h=t.locale.id;if(At[h][n])return At[h][n];for(c=n.replace(Zt,Lt).replace(Wt,Ft).split(Vt),i=[],r=-1,s=c.length,a={},l=[];++r<s;)o=c[r],o!=Tt?o.replace(ct,function(t,n,r,s){var o,c,f;(f=ot[r])&&(f.k&&(i.push(f.k),f.fn&&(a[f.k]=f.fn)),f.combo&&(c=f.combo.pluck("k"),o=u(f.combo.pluck("fn"),c),i.push.apply(i,c),e.copy(a,o,!0)),f.re&&l.push(n,f.re,s))}):(l.push(c[++r]),++r);return At[h][n]=f.bind(null,new RegExp(l.join("")),i,a)}function f(e,n,r,i){var s=new t,a=i.match(e),o=u(a.slice(1),n);return Object.reduce(o,function(e,t,n){return"string"==typeof t&&r[n]&&(o[n]=r[n](t,o)),e},null),isNaN(o[Dt])?(g(s,o[vt],o[Nt],o[Yt],o[wt]),h(s,o),m(s,o[jt])):s.setTime(o[Dt]),s}function h(n,r){var i,u,a,o,c=t.locale,l=-1;if(!Ct.every(e.has.bind(null,r))){if(isNaN(r[xt])&&(r[xt]=n.getFullYear()),isNaN(r[Ot])&&(a=c.isLeapYear(r[xt])?1:0,o=c.ordinal_day_count[a],u=o.length,r[Ot]=0,r[St]&&!r[yt]&&(i=r[Mt],i=isNaN(i)?0:i?i:7,r[yt]=r[St]*7-(4-i)),!isNaN(r[yt])))for(r[yt]>o[o.length-1]&&(r[yt]-=o[o.length-1],++r[xt]);++l<u;)if(s(r[yt],o[l],o[l+1])){r[Ot]=l,r[kt]=o[l]==0?r[yt]:r[yt]-o[l];break}isNaN(r[kt])&&(r[kt]=1),n.setDate(r[kt]),n.setYear(r[xt]),n.setMonth(r[Ot])}}function g(e,t,n,r,i){e.setHours(t||0),e.setMinutes(n||0),e.setSeconds(r||0),e.setMilliseconds(i||0)}function m(e,n){!s(n,-43200,50400)||e.adjust(t.SECOND,-e.getTimezoneOffset()*60-n)}function d(n,r){switch(e.ntype(n)){case"number":case"string":if(!q(new t(n))){r||(r=n),n=t.now();break}n=new t(n);case"array":case"object":r=n,n=t.now();break;case"date":if(q(new t(+n)))break;default:n=t.now()}var i,u=+n-+this,s=0>u?1:u>0?-1:0;return s?i=b(Math.abs(u),_(r)):(i=e.obj(),i.value=0),i.tense=s,i}function p(e,t,n,r){var i;return e.__ms__?e.excl[t[0]]?r[n+1]&&!e.excl[r[n+1][0]]||!(t=r[n-1])?e:(i=e.__ms__/t[1],e.__ms__=Math.round(i)*t[1]+e.__ms__/r[n][1]%1*r[n][1],p(e,t,n-1,[])):(e.__ms__>=t[1]&&(i=e.__ms__/t[1],t[0]in e.val?(i=Math.floor(i),e.__ms__-=i*t[1],e.val[t[0]]+=i):(e.__ms__=i%1*t[1],e.val[t[0]]=Math.floor(i))),e):e}function b(t,n){var r=Qt.reduce(p,{__ms__:t,excl:n,val:e.obj()}).val;return r.value=t,r}function _(t){var n=e.obj(),r=!0;if(t)switch(e.ntype(t)){case"object":r=!1;break;case"string":t=t.split(" ");case"array":t=t.reduce(k,n),r=!!e.len(n)}return Xt.map(function(e){e in this||(this[e]=!r)},n),n}function k(e,t){var n=(t=String(t).toLowerCase()).substring(1);switch(t.charAt(0)){case"-":e[n]=!0;break;case"+":e[n]=!1;break;case">":Qt.map(M,{excl:e,prop:n,val:!0});break;case"<":Qt.slice().reverse().map(M,{excl:e,prop:n,val:!1});break;default:e[t]=!1}return e}function M(e){e[0]===this.prop&&(this.SET_VALID=!0),this.SET_VALID&&(this.excl[e[0]]=this.val)}function y(t){return t=e.copy(t),e.remove(t,"tense","value"),Object.keys(t).map(function(e){return[Xt.indexOf(e),e]}).sort(function(e,t){return e=e[0],t=t[0],e>t?1:-1}).pluck(1)}function v(e,n){return(e=Number(e))<12&&r(n.ampm)==r(t.locale.PM)?e+=12:e}function w(e,t,n){return e.adjust(n,t)}function N(t){return Et.reduce(function(e,n,r){var i=parseFloat(t[r]);return isNaN(i)||0===i||(e[n]=i),e},e.obj())}function O(e){return Math.floor((e-C.call(e))/ft)}function Y(e){"Z"==e&&(e="0000");var t=!!e.indexOf("-"),n=e.match(Jt),r=(Number(n[1])+n[2]/60)*3600;return t?r:-r}function j(e){return Math.floor(Math.abs(O(e)/7))}function D(e,t){return isNaN(t)?Number(e)-1:t==e?0:Number(t)}function S(n,r){var i,u,s,a=this;switch(e.ntype(n)){case"number":n=arguments;case"array":n=N(n);case"object":Object.reduce(n,w,a);break;case"string":u=Ht[n.toLowerCase()],u&&0!==r&&(t.locale.setLeapYear(a),u==Ht.month&&(i=a.getDate(),28>i||a.setDate(Math.min(i,U.call(H.call(a).adjust(t.MONTH,r)).getDate()))),u!=Ht.week||(s=a.getDay()),a[u[1]](a[u[0]]()+r),!s||a.setDate(a.getDate()+s))}return a}function x(e,t){return+this>=+e&&+t>=+this}function T(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this}function L(){return new t(this.getTime())}function F(){var e=t.locale;return e.setLeapYear(this),e.day_count.slice(0,this.getMonth()).reduce(o,0)+this.getDate()-1}function H(){return new t(this.getFullYear(),this.getMonth(),1)}function E(e){var t=this.getTimezoneOffset();return[t>0?"-":"+",a(Math.floor(Math.abs(t)/60),2),e?":":"",a(Math.abs(t%60),2)].join("")}function I(){return this.getDay()||7}function A(){return Math.ceil((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/ft)}function C(){var e=this.getFullYear();return new t(e,0,lt[new t(e,0,1).getDay()])}function z(){var e,n=this.getFullYear();return this>=C.call(new t(n+1,0,1))?1:(e=Math.floor((F.call(this)-I.call(this)+10)/7),0==e?R.call(new t(n-1,0,1))-j(this):e)}function R(){return Math.round((C.call(new t(this.getFullYear()+1,0,1))-C.call(this))/pt)}function U(){var e=t.locale,n=this.getMonth();return e.setLeapYear(this),new t(this.getFullYear(),n,e.day_count[n])}function W(){return Math.floor(F.call(this)/7)}function Z(){return new t(this.getFullYear(),0,1).getTimezoneOffset()!=this.getTimezoneOffset()}function P(){return t.locale.isLeapYear(this.getFullYear())}function G(e){return this.setMonth(0),this.setDate(1),this.adjust(t.DAY,7*e).getTime()}function K(){var e=this.toString().split(" ");return e.splice(4,e.length).join(" ").replace($t,"$1").replace(Bt,"")}function q(t){return e.ntype(t)=="date"&&!isNaN(+t)}function V(e){var n,r,i,u,s,a,o=t.locale.id;if(It[o][e])return It[o][e];for(n=[" var out=[];"],s=e.replace(Zt,Lt).replace(Wt,Ft).split(Vt),a=/^[^A-Za-z]*$/g,r=-1,i=s.length;++r<i;)u=s[r],u==Tt?(n.push(J(s[++r])),++r):a.test(u)?n.push(J(u)):n.push(B(u));return n.push('return out.join( "" );\n //@ sourceURL=d8/format/'+o+"/"+e),It[o][e]=new Function("filter","date",n.join("\n\n "))}function $(e){return V(e)(ut,this)}function B(e){return e.replace(ct,function(e,t,n,r){return J(t+"', filter."+n+"( date ), '"+r)})}function J(e){return"out.push( '"+e+"' );"}function Q(e,n){q(e)||(q(new t(e))?e=new t(e):(n=e,e=t.now()));var r=t.locale.lexicon;return typeof zt[n=String(n).toLowerCase()]!="function"&&(n=r.DEFAULT),+e-+this?zt[n].call(r,this,e).replace(qt," "):r.just_now}function X(e){return e.join(" ")}function et(e,t){var n=e.pop();return(e.length?e.join(this.delim)+" "+this.and+" "+n:n)+" "+this[t.tense<1?"ago":"from_now"]}function tt(n){switch(e.ntype(n)){case"object":if(n.id){Rt[n.id]=n;break}case"string":if(n in Rt){n=Rt[n];break}default:n=null}return e.ntype(n)=="object"&&(e.defs(t,{locale:{value:n},getOrdinal:n.getOrdinal,isLeapYear:n.isLeapYear,setLeapYear:n.setLeapYear},"w",!0),n.id in It||(It[n.id]=e.obj()),n.id in At||(At[n.id]=e.obj()),ut=nt(n),at=rt(n),ot=it(n)),t}function nt(n){var u={d:function(e){return a(e.getDate(),2)},D:function(e){return n.days[e.getDay()].substring(0,3)},j:function(e){return e.getDate()},l:function(e){return n.days[e.getDay()]},N:function(e){return I.call(e)},S:function(e){return n.getOrdinal(e.getDate())},w:function(e){return e.getDay()},z:function(e){return e.getDayOfYear()},W:function(e){return z.call(e)},F:function(e){return n.months[e.getMonth()]},m:function(e){return a(e.getMonth()+1,2)},M:function(e){return n.months[e.getMonth()].substring(0,3)},n:function(e){return e.getMonth()+1},t:function(e){return n.setLeapYear(e),n.day_count[e.getMonth()]},L:function(e){return e.isLeapYear()?1:0},o:function(e){var t=e.getMonth(),n=z.call(e);return e.getFullYear()+(1==n&&t>0?1:n>=52&&11>t?-1:0)},Y:function(e){return e.getFullYear()},y:function(e){return String(e.getFullYear()).substring(2,4)},a:function(e){return r(e.getHours()<12?n.AM:n.PM)},A:function(e){return i(e.getHours()<12?n.AM:n.PM)},g:function(e){return e.getHours()%12||12},G:function(e){return e.getHours()},h:function(e){return a(ut.g(e),2)},H:function(e){return a(ut.G(e),2)},i:function(e){return a(e.getMinutes(),2)},s:function(e){return a(e.getSeconds(),2)},u:function(e){return a(e.getMilliseconds(),3)},O:function(e){return E.call(e)},P:function(e){return E.call(e,!0)},T:function(e){return K.call(e)},Z:function(e){return e.getTimezoneOffset()*-60},c:function(e){return $.call(e,at.ISO_8601)},r:function(e){return $.call(e,at.RFC_2822)},U:function(e){return e.getTime()},e:function(e){return e.lexicalize("exact")},x:function(e){return e.lexicalize("approx")}};return st=Object.keys(u).sort().join(""),ct=new RegExp("([^"+st+"]*)(["+st+"])([^"+st+"]*)","g"),e.def(t,"filters",{value:ut=u},"w",!0),u}function rt(n){var r=e.copy({ISO_8601:"Y-m-d<T>H:i:s.u<Z>",ISO_8601_SHORT:"Y-m-d",RFC_850:"l, d-M-y H:i:s T",RFC_2822:"D, d M Y H:i:s O",sortable:"Y-m-d H:i:sO"},n.formats);return r.atom=r.ISO_8601,r.cookie=r.RFC_850,r.rss=r.RFC_2822,e.def(t,"formats",{value:at=r},"w",!0),r}function it(u){var s={d:{k:kt,fn:Number,re:Gt},D:{k:Mt,fn:n.bind(null,u.days_short),re:"("+u.days_short.join("|")+")"},j:{k:kt,fn:Number,re:Pt},l:{k:Mt,fn:n.bind(null,u.days),re:"("+u.days.join("|")+")"},N:{k:Mt,fn:D.bind(null,7),re:"([1-7])"},S:{re:"(?:"+u.ordinal.join("|")+")"},w:{k:Mt,fn:Number,re:"([0-6])"},z:{k:yt,fn:Number,re:"([0-9]{1,3})"},W:{k:St,fn:Number,re:Gt},F:{k:Ot,fn:n.bind(null,u.months),re:"("+u.months.join("|")+")"},m:{k:Ot,fn:D,re:Gt},M:{k:Ot,fn:n.bind(null,u.months_short),re:"("+u.months_short.join("|")+")"},n:{k:Ot,fn:D,re:Pt},t:{re:"[0-9]{2}"},L:{re:"(?:0|1)"},o:{k:xt,fn:Number,re:Kt},Y:{k:xt,fn:Number,re:Kt},y:{k:xt,fn:function(e){return e=Number(e),e+=30>e?2e3:1900},re:Gt},a:{k:_t,fn:e,re:Ut},A:{k:_t,fn:r,re:i(Ut)},g:{k:vt,fn:v,re:Pt},G:{k:vt,fn:Number,re:Pt},h:{k:vt,fn:v,re:Gt},H:{k:vt,fn:Number,re:Gt},i:{k:Nt,fn:Number,re:Gt},s:{k:Yt,fn:Number,re:Gt},u:{k:wt,fn:Number,re:"([0-9]{1,})"},O:{k:jt,fn:Y,re:"([\\+-][0-9]{4})"},P:{k:jt,fn:Y,re:"([\\+-][0-9]{2}:[0-9]{2})"},T:{re:"[A-Z]{1,4}"},Z:{k:jt,fn:Y,re:"(Z|[\\+-]?[0-9]{2}:?[0-9]{2})"},U:{k:Dt,fn:Number,re:"(-?[0-9]{1,})"}};return s.c={combo:[s.Y,s.m,s.d,s.H,s.i,s.s,s.u,s.P],re:[s.Y.re,"-",s.m.re,"-",s.d.re,"T",s.H.re,":",s.i.re,":",s.s.re,"(?:\\.",s.u.re,"){0,1}",s.Z.re,"{0,1}"].join("")},s.r={combo:[s.D,s.d,s.M,s.Y,s.H,s.i,s.s,s.O],re:[s.D.re,", ",s.d.re," ",s.M.re," ",s.Y.re," ",s.H.re,":",s.i.re,":",s.s.re," ",s.O.re].join("")},e.def(t,"parsers",{value:ot=s},"w",!0),s}var ut,st,at,ot,ct,lt=[9,1,0,-1,-2,4,3],ft=864e5,ht=36e5,gt=6e4,mt=2592e6,dt=1e3,pt=6048e5,bt=31536e6,_t="ampm",kt="day",Mt="dayweek",yt="dayyear",vt="hour",wt="ms",Nt="minute",Ot="month",Yt="second",jt="timezone",Dt="unix",St="week",xt="year",Tt="NOREPLACE",Lt="<"+Tt+"<",Ft=">END"+Tt+">",Ht={day:["getDate","setDate"],hr:["getHours","setHours"],min:["getMinutes","setMinutes"],month:["getMonth","setMonth"],ms:["getMilliseconds","setMilliseconds"],sec:["getSeconds","setSeconds"],week:["getWeek","setWeek"],year:["getFullYear","setFullYear"]},Et=[xt,Ot,St,kt,"hr",Nt.substring(0,3),Yt.substring(0,3),wt],It=e.obj(),At=e.obj(),Ct=[kt,Mt,yt,Ot,St,xt],zt=e.obj(),Rt=e.obj(),Ut="(am|pm)",Wt=/>/g,Zt=/</g,Pt="([0-9]{1,2})",Gt="([0-9]{2})",Kt="([0-9]{4})",qt=/\s{2,}/g,Vt=/[<>]/,$t=/[^\(]*\(([^\)]+)\)/g,Bt=/[^A-Z]+/g,Jt=/[\+-]?([0-9]{2}):?([0-9]{2})/,Qt=[[xt+"s",bt],[Ot+"s",mt],[St+"s",pt],[kt+"s",ft],[vt+"s",ht],[Nt+"s",gt],[Yt+"s",dt],[wt,1]],Xt=Qt.pluck(0);zt.approx=function(e,n){var r,i,u,s,a,o,c,l=this.a,f=e.diff(n),h=t.diffKeys(f),g=t.time_map,m=this.time_units;if(f.value<t.MS_MINUTE)return this.just_now;switch(h[0]){case"years":u=0;break;case"months":u=1;break;case"weeks":u=2;break;case"days":f.days<2&&(o=e.format("l")===n.format("l"),c=o||h[1]!="hours"||f.hours<25),u=3;break;case"hours":o=e.format("l")===n.format("l"),c=f.hours/24>=.75,l=this.an,u=4;break;case"minutes":u=5}if(i=(f.value-g[u][1]*f[h[0]])/g[u][1],c)return o?this.today:f.tense>0?this.tomorrow:this.yesterday;if(s=[],a=f.tense>0?this.from_now:this.ago,.1>i)switch(h[0]){case"years":case"months":case"weeks":if(f[h[0]]===1){s.push(f.tense<1?this.last:this.next,m[u][0]);break}default:!i||s.push(this.about),s.push(f[h[0]],m[u][f[h[0]]>1?1:0],a)}else.74>i?.24>i?r=this.just_over:(r=i>.24&&.4>i?this.almost:this.about,s.push(this.and,this.a,this.half)):s.push(this.almost,f[h[0]]+1,m[u][1],a);return r&&(s.push(m[u][f[h[0]]>1||s.length?1:0],a),s.unshift(r,f[h[0]])),typeof this.approx=="function"?this.approx.call(this,s,f):X.call(this,s,f)},zt.exact=function(e,n){var r,i=e.diff(n),u=this.time_units;return r=t.time_map.reduce(function(e,t,n){var r=i[t[0]];return!r||!u[n]||e.push(r+" "+u[n][r>1?1:0]),e},[]),r.length?typeof this.exact=="function"?this.exact.call(this,r,i):et.call(this,r,i):this.just_now},e.defs(t.prototype,{adjust:S,between:x,clearTime:T,clone:L,diff:d,format:$,getDayOfYear:F,getFirstOfTheMonth:H,getGMTOffset:E,getISODay:I,getISODaysInYear:A,getISOFirstMondayOfYear:C,getISOWeek:z,getISOWeeksInYear:R,getLastOfTheMonth:U,getWeek:W,isDST:Z,isLeapYear:P,lexicalize:Q,setWeek:G,timezone:K,valid:function(){return t.valid(this)}},"r"),e.defs(t,{DAY:kt,HOUR:"hr",MINUTE:Nt.substring(0,3),MILLISECOND:wt,MONTH:Ot,SECOND:Yt.substring(0,3),WEEK:St,YEAR:xt,MS_DAY:ft,MS_HOUR:ht,MS_MINUTE:gt,MS_MONTH:mt,MS_SECOND:dt,MS_WEEK:pt,MS_YEAR:bt,lexicon:{value:zt},time_map:{value:Qt},time_props:{value:Xt},coerce:c,diffKeys:y,localize:tt,toDate:c,valid:q},"r")}).x(Date)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null);
View
2  src/coerce.js
@@ -94,7 +94,7 @@
if ( isNaN( parsers[DAY] ) ) parsers[DAY] = 1;
- date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] ); date.setDate( parsers[DAY] );
+ date.setDate( parsers[DAY] ); date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] );
}
function parse_setTime( date, hr, min, sec, ms ) {
Please sign in to comment.
Something went wrong with that request. Please try again.