]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Added moment.fn.isSame with tests
authorIskren Chernev <iskren@tradeo.com>
Tue, 28 Aug 2012 08:04:48 +0000 (11:04 +0300)
committerIskren Chernev <iskren@tradeo.com>
Tue, 28 Aug 2012 08:04:48 +0000 (11:04 +0300)
min/moment.min.js
min/moment.min.pretty.js
moment.js
test/moment/is_same.js [new file with mode: 0644]

index 4c359231d792670f3fe094a8b4d2267e3a7fb12b..3dd18a06f648431c97c3178eeec1242cb86fcb42 100644 (file)
@@ -3,4 +3,4 @@
 // author : Tim Wood
 // license : MIT
 // momentjs.com
-(function(a,b){function G(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,a._a=null,this._lang=c||!1}function H(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=I(j/1e3),b.seconds=i%60,h+=I(i/60),b.minutes=h%60,g+=I(h/60),b.hours=g%24,f+=I(g/24),f+=e*7,b.days=f%30,d+=I(f/30),b.months=d%12,c+=I(d/12),b.years=c,this._lang=!1}function I(a){return a<0?Math.ceil(a):Math.floor(a)}function J(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function K(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function L(a){return Object.prototype.toString.call(a)==="[object Array]"}function M(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function N(b,c){var d,e;for(d=1;d<7;d++)b[d]=b[d]==null?d===2?1:0:b[d];return b[7]=c,e=new a(0),c?(e.setUTCFullYear(b[0],b[1],b[2]),e.setUTCHours(b[3],b[4],b[5],b[6])):(e.setFullYear(b[0],b[1],b[2]),e.setHours(b[3],b[4],b[5],b[6])),e._a=b,e}function O(a,b){var d,e,f=[];!b&&i&&(b=require("./lang/"+a));for(d=0;d<j.length;d++)b[j[d]]=b[j[d]]||g.en[j[d]];for(d=0;d<12;d++)e=c([2e3,d]),f[d]=new RegExp("^"+(b.months[d]||b.months(e,""))+"|^"+(b.monthsShort[d]||b.monthsShort(e,"")).replace(".",""),"i");return b.monthsParse=b.monthsParse||f,g[a]=b,b}function P(a){var b=typeof a=="string"&&a||a&&a._lang||null;return b?g[b]||O(b):c}function Q(a){return D[a]?"'+("+D[a]+")+'":a.replace(n,"").replace(/\\?'/g,"\\'")}function R(a){return P().longDateFormat[a]||a}function S(a){var b="var a,b;return '"+a.replace(l,Q)+"';",c=Function;return new c("t","v","o","p","m",b)}function T(a){return C[a]||(C[a]=S(a)),C[a]}function U(a,b){function d(d,e){return c[d].call?c[d](a,b):c[d][e]}var c=P(a);while(m.test(b))b=b.replace(m,R);return C[b]||(C[b]=S(b)),C[b](a,d,c.ordinal,J,c.meridiem)}function V(a){switch(a){case"DDDD":return r;case"YYYY":return s;case"S":case"SS":case"SSS":case"DDD":return q;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return t;case"Z":case"ZZ":return u;case"T":return v;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return p;default:return new RegExp(a.replace("\\",""))}}function W(a,b,c,d){var e;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(P().monthsParse[e].test(b)){c[1]=e;break}break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(z),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}}function X(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(l),f,g;for(f=0;f<e.length;f++)g=(V(e[f]).exec(a)||[])[0],a=a.replace(V(e[f]),""),W(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),c[3]+=d.tzh,c[4]+=d.tzm,N(c,d.isUTC)}function Y(a,b){var c,d=a.match(o)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=X(a,b[g]),e=U(new G(h),b[g]).match(o)||[],i=M(d,e),i<f&&(f=i,c=h);return c}function Z(b){var c="YYYY-MM-DDT",d;if(w.exec(b)){for(d=0;d<4;d++)if(y[d][1].exec(b)){c+=y[d][0];break}return u.exec(b)?X(b,c+" Z"):X(b,c)}return new a(b)}function $(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function _(a,b,c){var d=e(Math.abs(a)/1e3),f=e(d/60),g=e(f/60),h=e(g/24),i=e(h/365),j=d<45&&["s",d]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",e(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=c,$.apply({},j)}function ab(a,b){c.fn[a]=function(a){var c=this._isUTC?"UTC":"";return a!=null?(this._d["set"+c+b](a),this):this._d["get"+c+b]()}}function bb(a){c.duration.fn[a]=function(){return this._data[a]}}function cb(a,b){c.duration.fn["as"+a]=function(){return+this/b}}var c,d="1.7.0",e=Math.round,f,g={},h="en",i=typeof module!="undefined"&&module.exports,j="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),k=/^\/?Date\((\-?\d+)/i,l=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?)/g,m=/(LT|LL?L?L?)/g,n=/(^\[)|(\\)|\]$/g,o=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,p=/\d\d?/,q=/\d{1,3}/,r=/\d{3}/,s=/\d{1,4}/,t=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,u=/Z|[\+\-]\d\d:?\d\d/i,v=/T/i,w=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,x="YYYY-MM-DDTHH:mm:ssZ",y=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],z=/([\+\-]|\d\d)/gi,A="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),B={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},C={},D={M:"(a=t.month()+1)",MMM:'v("monthsShort",t.month())',MMMM:'v("months",t.month())',D:"(a=t.date())",DDD:"(a=new Date(t.year(),t.month(),t.date()),b=new Date(t.year(),0,1),a=~~(((a-b)/864e5)+1.5))",d:"(a=t.day())",dd:'v("weekdaysMin",t.day())',ddd:'v("weekdaysShort",t.day())',dddd:'v("weekdays",t.day())',w:"(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))",YY:"p(t.year()%100,2)",YYYY:"p(t.year(),4)",a:"m(t.hours(),t.minutes(),!0)",A:"m(t.hours(),t.minutes(),!1)",H:"t.hours()",h:"t.hours()%12||12",m:"t.minutes()",s:"t.seconds()",S:"~~(t.milliseconds()/100)",SS:"p(~~(t.milliseconds()/10),2)",SSS:"p(t.milliseconds(),3)",Z:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',ZZ:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'},E="DDD w M D d".split(" "),F="M D H h m s w".split(" ");while(E.length)f=E.pop(),D[f+"o"]=D[f]+"+o(a)";while(F.length)f=F.pop(),D[f+f]="p("+D[f]+",2)";D.DDDD="p("+D.DDD+",3)",c=function(d,e){if(d===null||d==="")return null;var f,g;return c.isMoment(d)?new G(new a(+d._d),d._isUTC,d._lang):(e?L(e)?f=Y(d,e):f=X(d,e):(g=k.exec(d),f=d===b?new a:g?new a(+g[1]):d instanceof a?d:L(d)?N(d):typeof d=="string"?Z(d):new a(d)),new G(f))},c.utc=function(a,b){return L(a)?new G(N(a,!0),!0):(typeof a=="string"&&!u.exec(a)&&(a+=" +0000",b&&(b+=" Z")),c(a,b).utc())},c.unix=function(a){return c(a*1e3)},c.duration=function(a,b){var d=c.isDuration(a),e=typeof a=="number",f=d?a._data:e?{}:a,g;return e&&(b?f[b]=a:f.milliseconds=a),g=new H(f),d&&(g._lang=a._lang),g},c.humanizeDuration=function(a,b,d){return c.duration(a,b===!0?null:b).humanize(b===!0?!0:d)},c.version=d,c.defaultFormat=x,c.lang=function(a,b){var d;if(!a)return h;(b||!g[a])&&O(a,b);if(g[a]){for(d=0;d<j.length;d++)c[j[d]]=g[a][j[d]];c.monthsParse=g[a].monthsParse,h=a}},c.langData=P,c.isMoment=function(a){return a instanceof G},c.isDuration=function(a){return a instanceof H},c.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),c.fn=G.prototype={clone:function(){return c(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?!M(this._a,(this._a[7]?c.utc(this):this).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return U(this,a?a:c.defaultFormat)},add:function(a,b){var d=b?c.duration(+b,a):c.duration(a);return K(this,d,1),this},subtract:function(a,b){var d=b?c.duration(+b,a):c.duration(a);return K(this,d,-1),this},diff:function(a,b,d){var f=this._isUTC?c(a).utc():c(a).local(),g=(this.zone()-f.zone())*6e4,h=this._d-f._d-g,i=this.year()-f.year(),j=this.month()-f.month(),k=this.date()-f.date(),l;return b==="months"?l=i*12+j+k/30:b==="years"?l=i+(j+k/30)/12:l=b==="seconds"?h/1e3:b==="minutes"?h/6e4:b==="hours"?h/36e5:b==="days"?h/864e5:b==="weeks"?h/6048e5:h,d?l:e(l)},from:function(a,b){return c.duration(this.diff(a)).lang(this._lang).humanize(!b)},fromNow:function(a){return this.from(c(),a)},calendar:function(){var a=this.diff(c().sod(),"days",!0),b=this.lang().calendar,d=b.sameElse,e=a<-6?d:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:d;return this.format(typeof e=="function"?e.apply(this):e)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<c([this.year()]).zone()||this.zone()<c([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return c.utc([this.year(),this.month()+1,0]).date()},lang:function(a){return a===b?P(this):(this._lang=a,this)}};for(f=0;f<A.length;f++)ab(A[f].toLowerCase(),A[f]);ab("year","FullYear"),c.duration.fn=H.prototype={weeks:function(){return I(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=_(b,!a,this.lang());return a&&(d=(b<=0?c.past:c.future).replace(/%s/i,d)),d},lang:c.fn.lang};for(f in B)B.hasOwnProperty(f)&&(cb(f,B[f]),bb(f.toLowerCase()));cb("Weeks",6048e5),i&&(module.exports=c),typeof ender=="undefined"&&(this.moment=c),typeof define=="function"&&define.amd&&define("moment",[],function(){return c})}).call(this,Date);
\ No newline at end of file
+(function(e,t){function D(e,t,n){this._d=e,this._isUTC=!!t,this._a=e._a||null,e._a=null,this._lang=n||!1}function P(e){var t=this._data={},n=e.years||e.y||0,r=e.months||e.M||0,i=e.weeks||e.w||0,s=e.days||e.d||0,o=e.hours||e.h||0,u=e.minutes||e.m||0,a=e.seconds||e.s||0,f=e.milliseconds||e.ms||0;this._milliseconds=f+a*1e3+u*6e4+o*36e5,this._days=s+i*7,this._months=r+n*12,t.milliseconds=f%1e3,a+=H(f/1e3),t.seconds=a%60,u+=H(a/60),t.minutes=u%60,o+=H(u/60),t.hours=o%24,s+=H(o/24),s+=i*7,t.days=s%30,r+=H(s/30),t.months=r%12,n+=H(r/12),t.years=n,this._lang=!1}function H(e){return e<0?Math.ceil(e):Math.floor(e)}function B(e,t){var n=e+"";while(n.length<t)n="0"+n;return n}function j(e,t,n){var r=t._milliseconds,i=t._days,s=t._months,o;r&&e._d.setTime(+e+r*n),i&&e.date(e.date()+i*n),s&&(o=e.date(),e.date(1).month(e.month()+s*n).date(Math.min(o,e.daysInMonth())))}function F(e){return Object.prototype.toString.call(e)==="[object Array]"}function I(e,t){var n=Math.min(e.length,t.length),r=Math.abs(e.length-t.length),i=0,s;for(s=0;s<n;s++)~~e[s]!==~~t[s]&&i++;return i+r}function q(t,n){var r,i;for(r=1;r<7;r++)t[r]=t[r]==null?r===2?1:0:t[r];return t[7]=n,i=new e(0),n?(i.setUTCFullYear(t[0],t[1],t[2]),i.setUTCHours(t[3],t[4],t[5],t[6])):(i.setFullYear(t[0],t[1],t[2]),i.setHours(t[3],t[4],t[5],t[6])),i._a=t,i}function R(e,t){var r,i,s=[];!t&&a&&(t=require("./lang/"+e));for(r=0;r<f.length;r++)t[f[r]]=t[f[r]]||o.en[f[r]];for(r=0;r<12;r++)i=n([2e3,r]),s[r]=new RegExp("^"+(t.months[r]||t.months(i,""))+"|^"+(t.monthsShort[r]||t.monthsShort(i,"")).replace(".",""),"i");return t.monthsParse=t.monthsParse||s,o[e]=t,t}function U(e){var t=typeof e=="string"&&e||e&&e._lang||null;return t?o[t]||R(t):n}function z(e){return O[e]?"'+("+O[e]+")+'":e.replace(p,"").replace(/\\?'/g,"\\'")}function W(e){return U().longDateFormat[e]||e}function X(e){var t="var a,b;return '"+e.replace(c,z)+"';",n=Function;return new n("t","v","o","p","m",t)}function V(e){return A[e]||(A[e]=X(e)),A[e]}function $(e,t){function r(r,i){return n[r].call?n[r](e,t):n[r][i]}var n=U(e);while(h.test(t))t=t.replace(h,W);return A[t]||(A[t]=X(t)),A[t](e,r,n.ordinal,B,n.meridiem)}function J(e){switch(e){case"DDDD":return g;case"YYYY":return y;case"YYYYY":return b;case"S":case"SS":case"SSS":case"DDD":return m;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return w;case"Z":case"ZZ":return E;case"T":return S;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return v;default:return new RegExp(e.replace("\\",""))}}function K(e,t,n,r){var i;switch(e){case"M":case"MM":n[1]=t==null?0:~~t-1;break;case"MMM":case"MMMM":for(i=0;i<12;i++)if(U().monthsParse[i].test(t)){n[1]=i;break}break;case"D":case"DD":case"DDD":case"DDDD":t!=null&&(n[2]=~~t);break;case"YY":t=~~t,n[0]=t+(t>70?1900:2e3);break;case"YYYY":case"YYYYY":n[0]=~~t;break;case"a":case"A":r.isPm=(t+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":n[3]=~~t;break;case"m":case"mm":n[4]=~~t;break;case"s":case"ss":n[5]=~~t;break;case"S":case"SS":case"SSS":n[6]=~~(("0."+t)*1e3);break;case"Z":case"ZZ":r.isUTC=!0,i=(t+"").match(C),i&&i[1]&&(r.tzh=~~i[1]),i&&i[2]&&(r.tzm=~~i[2]),i&&i[0]==="+"&&(r.tzh=-r.tzh,r.tzm=-r.tzm)}}function Q(e,t){var n=[0,0,1,0,0,0,0],r={tzh:0,tzm:0},i=t.match(c),s,o;for(s=0;s<i.length;s++)o=(J(i[s]).exec(e)||[])[0],e=e.replace(J(i[s]),""),K(i[s],o,n,r);return r.isPm&&n[3]<12&&(n[3]+=12),r.isPm===!1&&n[3]===12&&(n[3]=0),n[3]+=r.tzh,n[4]+=r.tzm,q(n,r.isUTC)}function G(e,t){var n,r=e.match(d)||[],i,s=99,o,u,a;for(o=0;o<t.length;o++)u=Q(e,t[o]),i=$(new D(u),t[o]).match(d)||[],a=I(r,i),a<s&&(s=a,n=u);return n}function Y(t){var n="YYYY-MM-DDT",r;if(x.exec(t)){for(r=0;r<4;r++)if(N[r][1].exec(t)){n+=N[r][0];break}return E.exec(t)?Q(t,n+" Z"):Q(t,n)}return new e(t)}function Z(e,t,n,r,i){var s=i.relativeTime[e];return typeof s=="function"?s(t||1,!!n,e,r):s.replace(/%d/i,t||1)}function et(e,t,n){var r=i(Math.abs(e)/1e3),s=i(r/60),o=i(s/60),u=i(o/24),a=i(u/365),f=r<45&&["s",r]||s===1&&["m"]||s<45&&["mm",s]||o===1&&["h"]||o<22&&["hh",o]||u===1&&["d"]||u<=25&&["dd",u]||u<=45&&["M"]||u<345&&["MM",i(u/30)]||a===1&&["y"]||["yy",a];return f[2]=t,f[3]=e>0,f[4]=n,Z.apply({},f)}function tt(e,t){n.fn[e]=function(e){var n=this._isUTC?"UTC":"";return e!=null?(this._d["set"+n+t](e),this):this._d["get"+n+t]()}}function nt(e){n.duration.fn[e]=function(){return this._data[e]}}function rt(e,t){n.duration.fn["as"+e]=function(){return+this/t}}var n,r="1.7.0",i=Math.round,s,o={},u="en",a=typeof module!="undefined"&&module.exports,f="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),l=/^\/?Date\((\-?\d+)/i,c=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYYY|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|-)/g,h=/(LT|LL?L?L?)/g,p=/(^\[)|(\\)|\]$/g,d=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,v=/\d\d?/,m=/\d{1,3}/,g=/\d{3}/,y=/\d{1,4}/,b=/[+\-]?\d{1,6}/,w=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,E=/Z|[\+\-]\d\d:?\d\d/i,S=/T/i,x=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,T="YYYY-MM-DDTHH:mm:ssZ",N=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],C=/([\+\-]|\d\d)/gi,k="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),L={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},A={},O={M:"(a=t.month()+1)",MMM:'v("monthsShort",t.month())',MMMM:'v("months",t.month())',D:"(a=t.date())",DDD:"(a=new Date(t.year(),t.month(),t.date()),b=new Date(t.year(),0,1),a=~~(((a-b)/864e5)+1.5))",d:"(a=t.day())",dd:'v("weekdaysMin",t.day())',ddd:'v("weekdaysShort",t.day())',dddd:'v("weekdays",t.day())',w:"(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))",YY:"p(t.year()%100,2)",YYYY:"p(t.year(),4)",YYYYY:"p(t.year(),5)",a:"m(t.hours(),t.minutes(),!0)",A:"m(t.hours(),t.minutes(),!1)",H:"t.hours()",h:"t.hours()%12||12",m:"t.minutes()",s:"t.seconds()",S:"~~(t.milliseconds()/100)",SS:"p(~~(t.milliseconds()/10),2)",SSS:"p(t.milliseconds(),3)",Z:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',ZZ:'((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'},M="DDD w M D d".split(" "),_="M D H h m s w".split(" ");while(M.length)s=M.pop(),O[s+"o"]=O[s]+"+o(a)";while(_.length)s=_.pop(),O[s+s]="p("+O[s]+",2)";O.DDDD="p("+O.DDD+",3)",n=function(r,i){if(r===null||r==="")return null;var s,o;return n.isMoment(r)?new D(new e(+r._d),r._isUTC,r._lang):(i?F(i)?s=G(r,i):s=Q(r,i):(o=l.exec(r),s=r===t?new e:o?new e(+o[1]):r instanceof e?r:F(r)?q(r):typeof r=="string"?Y(r):new e(r)),new D(s))},n.utc=function(e,t){return F(e)?new D(q(e,!0),!0):(typeof e=="string"&&!E.exec(e)&&(e+=" +0000",t&&(t+=" Z")),n(e,t).utc())},n.unix=function(e){return n(e*1e3)},n.duration=function(e,t){var r=n.isDuration(e),i=typeof e=="number",s=r?e._data:i?{}:e,o;return i&&(t?s[t]=e:s.milliseconds=e),o=new P(s),r&&(o._lang=e._lang),o},n.humanizeDuration=function(e,t,r){return n.duration(e,t===!0?null:t).humanize(t===!0?!0:r)},n.version=r,n.defaultFormat=T,n.lang=function(e,t){var r;if(!e)return u;(t||!o[e])&&R(e,t);if(o[e]){for(r=0;r<f.length;r++)n[f[r]]=o[e][f[r]];n.monthsParse=o[e].monthsParse,u=e}},n.langData=U,n.isMoment=function(e){return e instanceof D},n.isDuration=function(e){return e instanceof P},n.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(e){var t=e%10;return~~(e%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th"}}),n.fn=D.prototype={clone:function(){return n(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var e=this;return[e.year(),e.month(),e.date(),e.hours(),e.minutes(),e.seconds(),e.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?!I(this._a,(this._a[7]?n.utc(this):this).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(e){return $(this,e?e:n.defaultFormat)},add:function(e,t){var r=t?n.duration(+t,e):n.duration(e);return j(this,r,1),this},subtract:function(e,t){var r=t?n.duration(+t,e):n.duration(e);return j(this,r,-1),this},diff:function(e,t,r){var s=this._isUTC?n(e).utc():n(e).local(),o=(this.zone()-s.zone())*6e4,u=this._d-s._d-o,a=this.year()-s.year(),f=this.month()-s.month(),l=this.date()-s.date(),c;return t==="months"?c=a*12+f+l/30:t==="years"?c=a+(f+l/30)/12:c=t==="seconds"?u/1e3:t==="minutes"?u/6e4:t==="hours"?u/36e5:t==="days"?u/864e5:t==="weeks"?u/6048e5:u,r?c:i(c)},from:function(e,t){return n.duration(this.diff(e)).lang(this._lang).humanize(!t)},fromNow:function(e){return this.from(n(),e)},calendar:function(){var e=this.diff(n().sod(),"days",!0),t=this.lang().calendar,r=t.sameElse,i=e<-6?r:e<-1?t.lastWeek:e<0?t.lastDay:e<1?t.sameDay:e<2?t.nextDay:e<7?t.nextWeek:r;return this.format(typeof i=="function"?i.apply(this):i)},isLeapYear:function(){var e=this.year();return e%4===0&&e%100!==0||e%400===0},isDST:function(){return this.zone()<n([this.year()]).zone()||this.zone()<n([this.year(),5]).zone()},day:function(e){var t=this._isUTC?this._d.getUTCDay():this._d.getDay();return e==null?t:this.add({d:e-t})},startOf:function(e){switch(e.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(e){return this.startOf(e).add(e.replace(/s?$/,"s"),1).subtract("ms",1)},isSame:function(e,t){return+this.startOf(t)===+n(e).startOf(t)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return n.utc([this.year(),this.month()+1,0]).date()},lang:function(e){return e===t?U(this):(this._lang=e,this)}};for(s=0;s<k.length;s++)tt(k[s].toLowerCase(),k[s]);tt("year","FullYear"),n.duration.fn=P.prototype={weeks:function(){return H(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(e){var t=+this,n=this.lang().relativeTime,r=et(t,!e,this.lang());return e&&(r=(t<=0?n.past:n.future).replace(/%s/i,r)),r},lang:n.fn.lang};for(s in L)L.hasOwnProperty(s)&&(rt(s,L[s]),nt(s.toLowerCase()));rt("Weeks",6048e5),a&&(module.exports=n),typeof ender=="undefined"&&(this.moment=n),typeof define=="function"&&define.amd&&define("moment",[],function(){return n})}).call(this,Date);
\ No newline at end of file
index 9b339f145726a4e9a233d99e5ccefb98f1f29f8b..071abcee5ea5c57cab53644b5ae59a267c23903c 100644 (file)
@@ -3,82 +3,84 @@
 // author : Tim Wood
 // license : MIT
 // momentjs.com
-(function(a, b) {
-    function G(a, b, c) {
-        this._d = a, this._isUTC = !!b, this._a = a._a || null, a._a = null, this._lang = c || !1;
+(function(e, t) {
+    function D(e, t, n) {
+        this._d = e, this._isUTC = !!t, this._a = e._a || null, e._a = null, this._lang = n || !1;
     }
-    function H(a) {
-        var b = this._data = {}, c = a.years || a.y || 0, d = a.months || a.M || 0, e = a.weeks || a.w || 0, f = a.days || a.d || 0, g = a.hours || a.h || 0, h = a.minutes || a.m || 0, i = a.seconds || a.s || 0, j = a.milliseconds || a.ms || 0;
-        this._milliseconds = j + i * 1e3 + h * 6e4 + g * 36e5, this._days = f + e * 7, this._months = d + c * 12, b.milliseconds = j % 1e3, i += I(j / 1e3), b.seconds = i % 60, h += I(i / 60), b.minutes = h % 60, g += I(h / 60), b.hours = g % 24, f += I(g / 24), f += e * 7, b.days = f % 30, d += I(f / 30), b.months = d % 12, c += I(d / 12), b.years = c, this._lang = !1;
+    function P(e) {
+        var t = this._data = {}, n = e.years || e.y || 0, r = e.months || e.M || 0, i = e.weeks || e.w || 0, s = e.days || e.d || 0, o = e.hours || e.h || 0, u = e.minutes || e.m || 0, a = e.seconds || e.s || 0, f = e.milliseconds || e.ms || 0;
+        this._milliseconds = f + a * 1e3 + u * 6e4 + o * 36e5, this._days = s + i * 7, this._months = r + n * 12, t.milliseconds = f % 1e3, a += H(f / 1e3), t.seconds = a % 60, u += H(a / 60), t.minutes = u % 60, o += H(u / 60), t.hours = o % 24, s += H(o / 24), s += i * 7, t.days = s % 30, r += H(s / 30), t.months = r % 12, n += H(r / 12), t.years = n, this._lang = !1;
     }
-    function I(a) {
-        return a < 0 ? Math.ceil(a) : Math.floor(a);
+    function H(e) {
+        return e < 0 ? Math.ceil(e) : Math.floor(e);
     }
-    function J(a, b) {
-        var c = a + "";
-        while (c.length < b) c = "0" + c;
-        return c;
+    function B(e, t) {
+        var n = e + "";
+        while (n.length < t) n = "0" + n;
+        return n;
     }
-    function K(a, b, c) {
-        var d = b._milliseconds, e = b._days, f = b._months, g;
-        d && a._d.setTime(+a + d * c), e && a.date(a.date() + e * c), f && (g = a.date(), a.date(1).month(a.month() + f * c).date(Math.min(g, a.daysInMonth())));
+    function j(e, t, n) {
+        var r = t._milliseconds, i = t._days, s = t._months, o;
+        r && e._d.setTime(+e + r * n), i && e.date(e.date() + i * n), s && (o = e.date(), e.date(1).month(e.month() + s * n).date(Math.min(o, e.daysInMonth())));
     }
-    function L(a) {
-        return Object.prototype.toString.call(a) === "[object Array]";
+    function F(e) {
+        return Object.prototype.toString.call(e) === "[object Array]";
     }
-    function M(a, b) {
-        var c = Math.min(a.length, b.length), d = Math.abs(a.length - b.length), e = 0, f;
-        for (f = 0; f < c; f++) ~~a[f] !== ~~b[f] && e++;
-        return e + d;
+    function I(e, t) {
+        var n = Math.min(e.length, t.length), r = Math.abs(e.length - t.length), i = 0, s;
+        for (s = 0; s < n; s++) ~~e[s] !== ~~t[s] && i++;
+        return i + r;
     }
-    function N(b, c) {
-        var d, e;
-        for (d = 1; d < 7; d++) b[d] = b[d] == null ? d === 2 ? 1 : 0 : b[d];
-        return b[7] = c, e = new a(0), c ? (e.setUTCFullYear(b[0], b[1], b[2]), e.setUTCHours(b[3], b[4], b[5], b[6])) : (e.setFullYear(b[0], b[1], b[2]), e.setHours(b[3], b[4], b[5], b[6])), e._a = b, e;
+    function q(t, n) {
+        var r, i;
+        for (r = 1; r < 7; r++) t[r] = t[r] == null ? r === 2 ? 1 : 0 : t[r];
+        return t[7] = n, i = new e(0), n ? (i.setUTCFullYear(t[0], t[1], t[2]), i.setUTCHours(t[3], t[4], t[5], t[6])) : (i.setFullYear(t[0], t[1], t[2]), i.setHours(t[3], t[4], t[5], t[6])), i._a = t, i;
     }
-    function O(a, b) {
-        var d, e, f = [];
-        !b && i && (b = require("./lang/" + a));
-        for (d = 0; d < j.length; d++) b[j[d]] = b[j[d]] || g.en[j[d]];
-        for (d = 0; d < 12; d++) e = c([ 2e3, d ]), f[d] = new RegExp("^" + (b.months[d] || b.months(e, "")) + "|^" + (b.monthsShort[d] || b.monthsShort(e, "")).replace(".", ""), "i");
-        return b.monthsParse = b.monthsParse || f, g[a] = b, b;
+    function R(e, t) {
+        var r, i, s = [];
+        !t && a && (t = require("./lang/" + e));
+        for (r = 0; r < f.length; r++) t[f[r]] = t[f[r]] || o.en[f[r]];
+        for (r = 0; r < 12; r++) i = n([ 2e3, r ]), s[r] = new RegExp("^" + (t.months[r] || t.months(i, "")) + "|^" + (t.monthsShort[r] || t.monthsShort(i, "")).replace(".", ""), "i");
+        return t.monthsParse = t.monthsParse || s, o[e] = t, t;
     }
-    function P(a) {
-        var b = typeof a == "string" && a || a && a._lang || null;
-        return b ? g[b] || O(b) : c;
+    function U(e) {
+        var t = typeof e == "string" && e || e && e._lang || null;
+        return t ? o[t] || R(t) : n;
     }
-    function Q(a) {
-        return D[a] ? "'+(" + D[a] + ")+'" : a.replace(n, "").replace(/\\?'/g, "\\'");
+    function z(e) {
+        return O[e] ? "'+(" + O[e] + ")+'" : e.replace(p, "").replace(/\\?'/g, "\\'");
     }
-    function R(a) {
-        return P().longDateFormat[a] || a;
+    function W(e) {
+        return U().longDateFormat[e] || e;
     }
-    function S(a) {
-        var b = "var a,b;return '" + a.replace(l, Q) + "';", c = Function;
-        return new c("t", "v", "o", "p", "m", b);
+    function X(e) {
+        var t = "var a,b;return '" + e.replace(c, z) + "';", n = Function;
+        return new n("t", "v", "o", "p", "m", t);
     }
-    function T(a) {
-        return C[a] || (C[a] = S(a)), C[a];
+    function V(e) {
+        return A[e] || (A[e] = X(e)), A[e];
     }
-    function U(a, b) {
-        function d(d, e) {
-            return c[d].call ? c[d](a, b) : c[d][e];
+    function $(e, t) {
+        function r(r, i) {
+            return n[r].call ? n[r](e, t) : n[r][i];
         }
-        var c = P(a);
-        while (m.test(b)) b = b.replace(m, R);
-        return C[b] || (C[b] = S(b)), C[b](a, d, c.ordinal, J, c.meridiem);
+        var n = U(e);
+        while (h.test(t)) t = t.replace(h, W);
+        return A[t] || (A[t] = X(t)), A[t](e, r, n.ordinal, B, n.meridiem);
     }
-    function V(a) {
-        switch (a) {
+    function J(e) {
+        switch (e) {
           case "DDDD":
-            return r;
+            return g;
           case "YYYY":
-            return s;
+            return y;
+          case "YYYYY":
+            return b;
           case "S":
           case "SS":
           case "SSS":
           case "DDD":
-            return q;
+            return m;
           case "MMM":
           case "MMMM":
           case "dd":
           case "dddd":
           case "a":
           case "A":
-            return t;
+            return w;
           case "Z":
           case "ZZ":
-            return u;
+            return E;
           case "T":
-            return v;
+            return S;
           case "MM":
           case "DD":
           case "YY":
           case "h":
           case "m":
           case "s":
-            return p;
+            return v;
           default:
-            return new RegExp(a.replace("\\", ""));
+            return new RegExp(e.replace("\\", ""));
         }
     }
-    function W(a, b, c, d) {
-        var e;
-        switch (a) {
+    function K(e, t, n, r) {
+        var i;
+        switch (e) {
           case "M":
           case "MM":
-            c[1] = b == null ? 0 : ~~b - 1;
+            n[1] = t == null ? 0 : ~~t - 1;
             break;
           case "MMM":
           case "MMMM":
-            for (e = 0; e < 12; e++) if (P().monthsParse[e].test(b)) {
-                c[1] = e;
+            for (i = 0; i < 12; i++) if (U().monthsParse[i].test(t)) {
+                n[1] = i;
                 break;
             }
             break;
           case "DD":
           case "DDD":
           case "DDDD":
-            b != null && (c[2] = ~~b);
+            t != null && (n[2] = ~~t);
             break;
           case "YY":
-            b = ~~b, c[0] = b + (b > 70 ? 1900 : 2e3);
+            t = ~~t, n[0] = t + (t > 70 ? 1900 : 2e3);
             break;
           case "YYYY":
-            c[0] = ~~Math.abs(b);
+          case "YYYYY":
+            n[0] = ~~t;
             break;
           case "a":
           case "A":
-            d.isPm = (b + "").toLowerCase() === "pm";
+            r.isPm = (t + "").toLowerCase() === "pm";
             break;
           case "H":
           case "HH":
           case "h":
           case "hh":
-            c[3] = ~~b;
+            n[3] = ~~t;
             break;
           case "m":
           case "mm":
-            c[4] = ~~b;
+            n[4] = ~~t;
             break;
           case "s":
           case "ss":
-            c[5] = ~~b;
+            n[5] = ~~t;
             break;
           case "S":
           case "SS":
           case "SSS":
-            c[6] = ~~(("0." + b) * 1e3);
+            n[6] = ~~(("0." + t) * 1e3);
             break;
           case "Z":
           case "ZZ":
-            d.isUTC = !0, e = (b + "").match(z), e && e[1] && (d.tzh = ~~e[1]), e && e[2] && (d.tzm = ~~e[2]), e && e[0] === "+" && (d.tzh = -d.tzh, d.tzm = -d.tzm);
+            r.isUTC = !0, i = (t + "").match(C), i && i[1] && (r.tzh = ~~i[1]), i && i[2] && (r.tzm = ~~i[2]), i && i[0] === "+" && (r.tzh = -r.tzh, r.tzm = -r.tzm);
         }
     }
-    function X(a, b) {
-        var c = [ 0, 0, 1, 0, 0, 0, 0 ], d = {
+    function Q(e, t) {
+        var n = [ 0, 0, 1, 0, 0, 0, 0 ], r = {
             tzh: 0,
             tzm: 0
-        }, e = b.match(l), f, g;
-        for (f = 0; f < e.length; f++) g = (V(e[f]).exec(a) || [])[0], a = a.replace(V(e[f]), ""), W(e[f], g, c, d);
-        return d.isPm && c[3] < 12 && (c[3] += 12), d.isPm === !1 && c[3] === 12 && (c[3] = 0), c[3] += d.tzh, c[4] += d.tzm, N(c, d.isUTC);
+        }, i = t.match(c), s, o;
+        for (s = 0; s < i.length; s++) o = (J(i[s]).exec(e) || [])[0], e = e.replace(J(i[s]), ""), K(i[s], o, n, r);
+        return r.isPm && n[3] < 12 && (n[3] += 12), r.isPm === !1 && n[3] === 12 && (n[3] = 0), n[3] += r.tzh, n[4] += r.tzm, q(n, r.isUTC);
     }
-    function Y(a, b) {
-        var c, d = a.match(o) || [], e, f = 99, g, h, i;
-        for (g = 0; g < b.length; g++) h = X(a, b[g]), e = U(new G(h), b[g]).match(o) || [], i = M(d, e), i < f && (f = i, c = h);
-        return c;
+    function G(e, t) {
+        var n, r = e.match(d) || [], i, s = 99, o, u, a;
+        for (o = 0; o < t.length; o++) u = Q(e, t[o]), i = $(new D(u), t[o]).match(d) || [], a = I(r, i), a < s && (s = a, n = u);
+        return n;
     }
-    function Z(b) {
-        var c = "YYYY-MM-DDT", d;
-        if (w.exec(b)) {
-            for (d = 0; d < 4; d++) if (y[d][1].exec(b)) {
-                c += y[d][0];
+    function Y(t) {
+        var n = "YYYY-MM-DDT", r;
+        if (x.exec(t)) {
+            for (r = 0; r < 4; r++) if (N[r][1].exec(t)) {
+                n += N[r][0];
                 break;
             }
-            return u.exec(b) ? X(b, c + " Z") : X(b, c);
+            return E.exec(t) ? Q(t, n + " Z") : Q(t, n);
         }
-        return new a(b);
+        return new e(t);
     }
-    function $(a, b, c, d, e) {
-        var f = e.relativeTime[a];
-        return typeof f == "function" ? f(b || 1, !!c, a, d) : f.replace(/%d/i, b || 1);
+    function Z(e, t, n, r, i) {
+        var s = i.relativeTime[e];
+        return typeof s == "function" ? s(t || 1, !!n, e, r) : s.replace(/%d/i, t || 1);
     }
-    function _(a, b, c) {
-        var d = e(Math.abs(a) / 1e3), f = e(d / 60), g = e(f / 60), h = e(g / 24), i = e(h / 365), j = d < 45 && [ "s", d ] || f === 1 && [ "m" ] || f < 45 && [ "mm", f ] || g === 1 && [ "h" ] || g < 22 && [ "hh", g ] || h === 1 && [ "d" ] || h <= 25 && [ "dd", h ] || h <= 45 && [ "M" ] || h < 345 && [ "MM", e(h / 30) ] || i === 1 && [ "y" ] || [ "yy", i ];
-        return j[2] = b, j[3] = a > 0, j[4] = c, $.apply({}, j);
+    function et(e, t, n) {
+        var r = i(Math.abs(e) / 1e3), s = i(r / 60), o = i(s / 60), u = i(o / 24), a = i(u / 365), f = r < 45 && [ "s", r ] || s === 1 && [ "m" ] || s < 45 && [ "mm", s ] || o === 1 && [ "h" ] || o < 22 && [ "hh", o ] || u === 1 && [ "d" ] || u <= 25 && [ "dd", u ] || u <= 45 && [ "M" ] || u < 345 && [ "MM", i(u / 30) ] || a === 1 && [ "y" ] || [ "yy", a ];
+        return f[2] = t, f[3] = e > 0, f[4] = n, Z.apply({}, f);
     }
-    function ab(a, b) {
-        c.fn[a] = function(a) {
-            var c = this._isUTC ? "UTC" : "";
-            return a != null ? (this._d["set" + c + b](a), this) : this._d["get" + c + b]();
+    function tt(e, t) {
+        n.fn[e] = function(e) {
+            var n = this._isUTC ? "UTC" : "";
+            return e != null ? (this._d["set" + n + t](e), this) : this._d["get" + n + t]();
         };
     }
-    function bb(a) {
-        c.duration.fn[a] = function() {
-            return this._data[a];
+    function nt(e) {
+        n.duration.fn[e] = function() {
+            return this._data[e];
         };
     }
-    function cb(a, b) {
-        c.duration.fn["as" + a] = function() {
-            return +this / b;
+    function rt(e, t) {
+        n.duration.fn["as" + e] = function() {
+            return +this / t;
         };
     }
-    var c, d = "1.7.0", e = Math.round, f, g = {}, h = "en", i = typeof module != "undefined" && module.exports, j = "months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"), k = /^\/?Date\((\-?\d+)/i, l = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?)/g, m = /(LT|LL?L?L?)/g, n = /(^\[)|(\\)|\]$/g, o = /([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi, p = /\d\d?/, q = /\d{1,3}/, r = /\d{3}/, s = /\d{1,4}/, t = /[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i, u = /Z|[\+\-]\d\d:?\d\d/i, v = /T/i, w = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/, x = "YYYY-MM-DDTHH:mm:ssZ", y = [ [ "HH:mm:ss.S", /T\d\d:\d\d:\d\d\.\d{1,3}/ ], [ "HH:mm:ss", /T\d\d:\d\d:\d\d/ ], [ "HH:mm", /T\d\d:\d\d/ ], [ "HH", /T\d\d/ ] ], z = /([\+\-]|\d\d)/gi, A = "Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"), B = {
+    var n, r = "1.7.0", i = Math.round, s, o = {}, u = "en", a = typeof module != "undefined" && module.exports, f = "months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"), l = /^\/?Date\((\-?\d+)/i, c = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYYY|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|-)/g, h = /(LT|LL?L?L?)/g, p = /(^\[)|(\\)|\]$/g, d = /([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi, v = /\d\d?/, m = /\d{1,3}/, g = /\d{3}/, y = /\d{1,4}/, b = /[+\-]?\d{1,6}/, w = /[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i, E = /Z|[\+\-]\d\d:?\d\d/i, S = /T/i, x = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/, T = "YYYY-MM-DDTHH:mm:ssZ", N = [ [ "HH:mm:ss.S", /T\d\d:\d\d:\d\d\.\d{1,3}/ ], [ "HH:mm:ss", /T\d\d:\d\d:\d\d/ ], [ "HH:mm", /T\d\d:\d\d/ ], [ "HH", /T\d\d/ ] ], C = /([\+\-]|\d\d)/gi, k = "Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"), L = {
         Milliseconds: 1,
         Seconds: 1e3,
         Minutes: 6e4,
         Days: 864e5,
         Months: 2592e6,
         Years: 31536e6
-    }, C = {}, D = {
+    }, A = {}, O = {
         M: "(a=t.month()+1)",
         MMM: 'v("monthsShort",t.month())',
         MMMM: 'v("months",t.month())',
         w: "(a=new Date(t.year(),t.month(),t.date()-t.day()+5),b=new Date(a.getFullYear(),0,4),a=~~((a-b)/864e5/7+1.5))",
         YY: "p(t.year()%100,2)",
         YYYY: "p(t.year(),4)",
+        YYYYY: "p(t.year(),5)",
         a: "m(t.hours(),t.minutes(),!0)",
         A: "m(t.hours(),t.minutes(),!1)",
         H: "t.hours()",
         SSS: "p(t.milliseconds(),3)",
         Z: '((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(a/60),2)+":"+p(~~a%60,2)',
         ZZ: '((a=-t.zone())<0?((a=-a),"-"):"+")+p(~~(10*a/6),4)'
-    }, E = "DDD w M D d".split(" "), F = "M D H h m s w".split(" ");
-    while (E.length) f = E.pop(), D[f + "o"] = D[f] + "+o(a)";
-    while (F.length) f = F.pop(), D[f + f] = "p(" + D[f] + ",2)";
-    D.DDDD = "p(" + D.DDD + ",3)", c = function(d, e) {
-        if (d === null || d === "") return null;
-        var f, g;
-        return c.isMoment(d) ? new G(new a(+d._d), d._isUTC, d._lang) : (e ? L(e) ? f = Y(d, e) : f = X(d, e) : (g = k.exec(d), f = d === b ? new a : g ? new a(+g[1]) : d instanceof a ? d : L(d) ? N(d) : typeof d == "string" ? Z(d) : new a(d)), new G(f));
-    }, c.utc = function(a, b) {
-        return L(a) ? new G(N(a, !0), !0) : (typeof a == "string" && !u.exec(a) && (a += " +0000", b && (b += " Z")), c(a, b).utc());
-    }, c.unix = function(a) {
-        return c(a * 1e3);
-    }, c.duration = function(a, b) {
-        var d = c.isDuration(a), e = typeof a == "number", f = d ? a._data : e ? {} : a, g;
-        return e && (b ? f[b] = a : f.milliseconds = a), g = new H(f), d && (g._lang = a._lang), g;
-    }, c.humanizeDuration = function(a, b, d) {
-        return c.duration(a, b === !0 ? null : b).humanize(b === !0 ? !0 : d);
-    }, c.version = d, c.defaultFormat = x, c.lang = function(a, b) {
-        var d;
-        if (!a) return h;
-        (b || !g[a]) && O(a, b);
-        if (g[a]) {
-            for (d = 0; d < j.length; d++) c[j[d]] = g[a][j[d]];
-            c.monthsParse = g[a].monthsParse, h = a;
+    }, M = "DDD w M D d".split(" "), _ = "M D H h m s w".split(" ");
+    while (M.length) s = M.pop(), O[s + "o"] = O[s] + "+o(a)";
+    while (_.length) s = _.pop(), O[s + s] = "p(" + O[s] + ",2)";
+    O.DDDD = "p(" + O.DDD + ",3)", n = function(r, i) {
+        if (r === null || r === "") return null;
+        var s, o;
+        return n.isMoment(r) ? new D(new e(+r._d), r._isUTC, r._lang) : (i ? F(i) ? s = G(r, i) : s = Q(r, i) : (o = l.exec(r), s = r === t ? new e : o ? new e(+o[1]) : r instanceof e ? r : F(r) ? q(r) : typeof r == "string" ? Y(r) : new e(r)), new D(s));
+    }, n.utc = function(e, t) {
+        return F(e) ? new D(q(e, !0), !0) : (typeof e == "string" && !E.exec(e) && (e += " +0000", t && (t += " Z")), n(e, t).utc());
+    }, n.unix = function(e) {
+        return n(e * 1e3);
+    }, n.duration = function(e, t) {
+        var r = n.isDuration(e), i = typeof e == "number", s = r ? e._data : i ? {} : e, o;
+        return i && (t ? s[t] = e : s.milliseconds = e), o = new P(s), r && (o._lang = e._lang), o;
+    }, n.humanizeDuration = function(e, t, r) {
+        return n.duration(e, t === !0 ? null : t).humanize(t === !0 ? !0 : r);
+    }, n.version = r, n.defaultFormat = T, n.lang = function(e, t) {
+        var r;
+        if (!e) return u;
+        (t || !o[e]) && R(e, t);
+        if (o[e]) {
+            for (r = 0; r < f.length; r++) n[f[r]] = o[e][f[r]];
+            n.monthsParse = o[e].monthsParse, u = e;
         }
-    }, c.langData = P, c.isMoment = function(a) {
-        return a instanceof G;
-    }, c.isDuration = function(a) {
-        return a instanceof H;
-    }, c.lang("en", {
+    }, n.langData = U, n.isMoment = function(e) {
+        return e instanceof D;
+    }, n.isDuration = function(e) {
+        return e instanceof P;
+    }, n.lang("en", {
         months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
         monthsShort: "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
         weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
             LLL: "MMMM D YYYY LT",
             LLLL: "dddd, MMMM D YYYY LT"
         },
-        meridiem: function(a, b, c) {
-            return a > 11 ? c ? "pm" : "PM" : c ? "am" : "AM";
+        meridiem: function(e, t, n) {
+            return e > 11 ? n ? "pm" : "PM" : n ? "am" : "AM";
         },
         calendar: {
             sameDay: "[Today at] LT",
             y: "a year",
             yy: "%d years"
         },
-        ordinal: function(a) {
-            var b = a % 10;
-            return ~~(a % 100 / 10) === 1 ? "th" : b === 1 ? "st" : b === 2 ? "nd" : b === 3 ? "rd" : "th";
+        ordinal: function(e) {
+            var t = e % 10;
+            return ~~(e % 100 / 10) === 1 ? "th" : t === 1 ? "st" : t === 2 ? "nd" : t === 3 ? "rd" : "th";
         }
-    }), c.fn = G.prototype = {
+    }), n.fn = D.prototype = {
         clone: function() {
-            return c(this);
+            return n(this);
         },
         valueOf: function() {
             return +this._d;
             return this._d;
         },
         toArray: function() {
-            var a = this;
-            return [ a.year(), a.month(), a.date(), a.hours(), a.minutes(), a.seconds(), a.milliseconds(), !!this._isUTC ];
+            var e = this;
+            return [ e.year(), e.month(), e.date(), e.hours(), e.minutes(), e.seconds(), e.milliseconds(), !!this._isUTC ];
         },
         isValid: function() {
-            return this._a ? !M(this._a, (this._a[7] ? c.utc(this) : this).toArray()) : !isNaN(this._d.getTime());
+            return this._a ? !I(this._a, (this._a[7] ? n.utc(this) : this).toArray()) : !isNaN(this._d.getTime());
         },
         utc: function() {
             return this._isUTC = !0, this;
         local: function() {
             return this._isUTC = !1, this;
         },
-        format: function(a) {
-            return U(this, a ? a : c.defaultFormat);
+        format: function(e) {
+            return $(this, e ? e : n.defaultFormat);
         },
-        add: function(a, b) {
-            var d = b ? c.duration(+b, a) : c.duration(a);
-            return K(this, d, 1), this;
+        add: function(e, t) {
+            var r = t ? n.duration(+t, e) : n.duration(e);
+            return j(this, r, 1), this;
         },
-        subtract: function(a, b) {
-            var d = b ? c.duration(+b, a) : c.duration(a);
-            return K(this, d, -1), this;
+        subtract: function(e, t) {
+            var r = t ? n.duration(+t, e) : n.duration(e);
+            return j(this, r, -1), this;
         },
-        diff: function(a, b, d) {
-            var f = this._isUTC ? c(a).utc() : c(a).local(), g = (this.zone() - f.zone()) * 6e4, h = this._d - f._d - g, i = this.year() - f.year(), j = this.month() - f.month(), k = this.date() - f.date(), l;
-            return b === "months" ? l = i * 12 + j + k / 30 : b === "years" ? l = i + (j + k / 30) / 12 : l = b === "seconds" ? h / 1e3 : b === "minutes" ? h / 6e4 : b === "hours" ? h / 36e5 : b === "days" ? h / 864e5 : b === "weeks" ? h / 6048e5 : h, d ? l : e(l);
+        diff: function(e, t, r) {
+            var s = this._isUTC ? n(e).utc() : n(e).local(), o = (this.zone() - s.zone()) * 6e4, u = this._d - s._d - o, a = this.year() - s.year(), f = this.month() - s.month(), l = this.date() - s.date(), c;
+            return t === "months" ? c = a * 12 + f + l / 30 : t === "years" ? c = a + (f + l / 30) / 12 : c = t === "seconds" ? u / 1e3 : t === "minutes" ? u / 6e4 : t === "hours" ? u / 36e5 : t === "days" ? u / 864e5 : t === "weeks" ? u / 6048e5 : u, r ? c : i(c);
         },
-        from: function(a, b) {
-            return c.duration(this.diff(a)).lang(this._lang).humanize(!b);
+        from: function(e, t) {
+            return n.duration(this.diff(e)).lang(this._lang).humanize(!t);
         },
-        fromNow: function(a) {
-            return this.from(c(), a);
+        fromNow: function(e) {
+            return this.from(n(), e);
         },
         calendar: function() {
-            var a = this.diff(c().sod(), "days", !0), b = this.lang().calendar, d = b.sameElse, e = a < -6 ? d : a < -1 ? b.lastWeek : a < 0 ? b.lastDay : a < 1 ? b.sameDay : a < 2 ? b.nextDay : a < 7 ? b.nextWeek : d;
-            return this.format(typeof e == "function" ? e.apply(this) : e);
+            var e = this.diff(n().sod(), "days", !0), t = this.lang().calendar, r = t.sameElse, i = e < -6 ? r : e < -1 ? t.lastWeek : e < 0 ? t.lastDay : e < 1 ? t.sameDay : e < 2 ? t.nextDay : e < 7 ? t.nextWeek : r;
+            return this.format(typeof i == "function" ? i.apply(this) : i);
         },
         isLeapYear: function() {
-            var a = this.year();
-            return a % 4 === 0 && a % 100 !== 0 || a % 400 === 0;
+            var e = this.year();
+            return e % 4 === 0 && e % 100 !== 0 || e % 400 === 0;
         },
         isDST: function() {
-            return this.zone() < c([ this.year() ]).zone() || this.zone() < c([ this.year(), 5 ]).zone();
+            return this.zone() < n([ this.year() ]).zone() || this.zone() < n([ this.year(), 5 ]).zone();
         },
-        day: function(a) {
-            var b = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
-            return a == null ? b : this.add({
-                d: a - b
+        day: function(e) {
+            var t = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
+            return e == null ? t : this.add({
+                d: e - t
             });
         },
-        startOf: function(a) {
-            switch (a.replace(/s$/, "")) {
+        startOf: function(e) {
+            switch (e.replace(/s$/, "")) {
               case "year":
                 this.month(0);
               case "month":
             }
             return this;
         },
-        endOf: function(a) {
-            return this.startOf(a).add(a.replace(/s?$/, "s"), 1).subtract("ms", 1);
+        endOf: function(e) {
+            return this.startOf(e).add(e.replace(/s?$/, "s"), 1).subtract("ms", 1);
+        },
+        isSame: function(e, t) {
+            return +this.startOf(t) === +n(e).startOf(t);
         },
         sod: function() {
             return this.clone().startOf("day");
             return this._isUTC ? 0 : this._d.getTimezoneOffset();
         },
         daysInMonth: function() {
-            return c.utc([ this.year(), this.month() + 1, 0 ]).date();
+            return n.utc([ this.year(), this.month() + 1, 0 ]).date();
         },
-        lang: function(a) {
-            return a === b ? P(this) : (this._lang = a, this);
+        lang: function(e) {
+            return e === t ? U(this) : (this._lang = e, this);
         }
     };
-    for (f = 0; f < A.length; f++) ab(A[f].toLowerCase(), A[f]);
-    ab("year", "FullYear"), c.duration.fn = H.prototype = {
+    for (s = 0; s < k.length; s++) tt(k[s].toLowerCase(), k[s]);
+    tt("year", "FullYear"), n.duration.fn = P.prototype = {
         weeks: function() {
-            return I(this.days() / 7);
+            return H(this.days() / 7);
         },
         valueOf: function() {
             return this._milliseconds + this._days * 864e5 + this._months * 2592e6;
         },
-        humanize: function(a) {
-            var b = +this, c = this.lang().relativeTime, d = _(b, !a, this.lang());
-            return a && (d = (b <= 0 ? c.past : c.future).replace(/%s/i, d)), d;
+        humanize: function(e) {
+            var t = +this, n = this.lang().relativeTime, r = et(t, !e, this.lang());
+            return e && (r = (t <= 0 ? n.past : n.future).replace(/%s/i, r)), r;
         },
-        lang: c.fn.lang
+        lang: n.fn.lang
     };
-    for (f in B) B.hasOwnProperty(f) && (cb(f, B[f]), bb(f.toLowerCase()));
-    cb("Weeks", 6048e5), i && (module.exports = c), typeof ender == "undefined" && (this.moment = c), typeof define == "function" && define.amd && define("moment", [], function() {
-        return c;
+    for (s in L) L.hasOwnProperty(s) && (rt(s, L[s]), nt(s.toLowerCase()));
+    rt("Weeks", 6048e5), a && (module.exports = n), typeof ender == "undefined" && (this.moment = n), typeof define == "function" && define.amd && define("moment", [], function() {
+        return n;
     });
 }).call(this, Date);
\ No newline at end of file
index 1516deb9f2f60b3ae11668d38687acf9562abef0..19ef0e4a0116924ec44caa31707f217053e514e8 100644 (file)
--- a/moment.js
+++ b/moment.js
@@ -47,7 +47,7 @@
         parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 or Z
         parseTokenT = /T/i, // T (ISO seperator)
 
-        // preliminary iso regex 
+        // preliminary iso regex
         // 0000-00-00 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000
         isoRegex = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,
         isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
     function Duration(duration) {
         var data = this._data = {},
             years = duration.years || duration.y || 0,
-            months = duration.months || duration.M || 0, 
+            months = duration.months || duration.M || 0,
             weeks = duration.weeks || duration.w || 0,
             days = duration.days || duration.d || 0,
             hours = duration.hours || duration.h || 0,
         // it separately.
         this._months = months +
             years * 12;
-            
+
         // The following code bubbles up values, see the tests for
         // examples of what that means.
         data.milliseconds = milliseconds % 1000;
 
         days += weeks * 7;
         data.days = days % 30;
-        
+
         months += absRound(days / 30);
 
         data.months = months % 12;
         if (!values && hasModule) {
             values = require('./lang/' + key);
         }
-        
+
         for (i = 0; i < langConfigProperties.length; i++) {
             // If a language definition does not provide a value, inherit
             // from English
 
         for (i = 0; i < 12; i++) {
             m = moment([2000, i]);
-            parse[i] = new RegExp('^' + (values.months[i] || values.months(m, '')) + 
+            parse[i] = new RegExp('^' + (values.months[i] || values.months(m, '')) +
                 '|^' + (values.monthsShort[i] || values.monthsShort(m, '')).replace('.', ''), 'i');
         }
         values.monthsParse = values.monthsParse || parse;
 
         languages[key] = values;
-        
+
         return values;
     }
 
 
     // helper for building inline formatting functions
     function replaceFormatTokens(token) {
-        return formatFunctionStrings[token] ? 
+        return formatFunctionStrings[token] ?
             ("'+(" + formatFunctionStrings[token] + ")+'") :
             token.replace(formattingRemoveEscapes, "").replace(/\\?'/g, "\\'");
     }
                     break;
                 }
             }
-            return parseTokenTimezone.exec(string) ? 
+            return parseTokenTimezone.exec(string) ?
                 makeDateFromStringAndFormat(string, format + ' Z') :
                 makeDateFromStringAndFormat(string, format);
         }
         },
 
         isDST : function () {
-            return (this.zone() < moment([this.year()]).zone() || 
+            return (this.zone() < moment([this.year()]).zone() ||
                 this.zone() < moment([this.year(), 5]).zone());
         },
 
         endOf: function (val) {
             return this.startOf(val).add(val.replace(/s?$/, 's'), 1).subtract('ms', 1);
         },
-        
+
+        isSame: function (input, val) {
+            return +this.startOf(val) === +moment(input).startOf(val);
+        },
+
         sod: function () {
             return this.clone().startOf('day');
         },
diff --git a/test/moment/is_same.js b/test/moment/is_same.js
new file mode 100644 (file)
index 0000000..d65696a
--- /dev/null
@@ -0,0 +1,102 @@
+var moment = require("../../moment");
+
+exports.is_same = {
+    "is same year" : function(test) {
+        test.expect(7);
+
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6));
+        test.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), true, "year match");
+        test.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), true, "exact start of year");
+        test.equal(m.isSame(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), true, "exact end of year");
+        test.equal(m.isSame(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, "start of next year");
+        test.equal(m.isSame(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, "end of previous year");
+        test.done();
+    },
+
+    "is same month" : function(test) {
+        test.expect(8);
+
+        var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7));
+        test.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), true, "month match");
+        test.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, "month mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, "exact start of month");
+        test.equal(m.isSame(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), true, "exact end of month");
+        test.equal(m.isSame(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, "start of next month");
+        test.equal(m.isSame(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, "end of previous month");
+        test.done();
+    },
+
+    "is same day" : function(test) {
+        test.expect(9);
+
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6));
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), true, "day match");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, "month mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), false, "day mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day'), true, "exact start of day");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day'), true, "exact end of day");
+        test.equal(m.isSame(moment(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day'), false, "start of next day");
+        test.equal(m.isSame(moment(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day'), false, "end of previous day");
+        test.done();
+    },
+
+    "is same hour" : function(test) {
+        test.expect(10);
+
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6));
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, "hour match");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour'), false, "month mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour'), false, "day mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour'), false, "hour mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour'), true, "exact start of hour");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour'), true, "exact end of hour");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), false, "start of next hour");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour'), false, "end of previous hour");
+        test.done();
+    },
+
+    "is same minute" : function(test) {
+        test.expect(11);
+
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6));
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), true, "minute match");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, "month mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute'), false, "day mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute'), false, "hour mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute'), false, "minute mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute'), true, "exact start of minute");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute'), true, "exact end of minute");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), false, "start of next minute");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, "end of previous minute");
+        test.done();
+    },
+
+    "is same second" : function(test) {
+        test.expect(12);
+
+        var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6));
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), true, "second match");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds'), true, "plural should work");
+        test.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second'), false, "year mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, "month mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second'), false, "day mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second'), false, "hour mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second'), false, "minute mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second'), false, "second mismatch");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second'), true, "exact start of second");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second'), true, "exact end of second");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), false, "start of next second");
+        test.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, "end of previous second");
+        test.done();
+    }
+};