]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Commenting and organizing sections
authorTim Wood <washwithcare@gmail.com>
Wed, 6 Jun 2012 21:45:54 +0000 (14:45 -0700)
committerTim Wood <washwithcare@gmail.com>
Wed, 6 Jun 2012 21:45:54 +0000 (14:45 -0700)
min/moment.min.js
min/moment.min.pretty.js
moment.js

index 0e8ee07166e70366d0462c27cd5a4b780d5885be..47689168663f242858bb49fc754dbaad5b5cd5f4 100644 (file)
@@ -3,4 +3,4 @@
 // author : Tim Wood
 // license : MIT
 // momentjs.com
-(function(a,b){function G(a,b){this._d=a,this._isUTC=!!b}function H(a){return a<0?Math.ceil(a):Math.floor(a)}function I(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+=H(j/1e3),b.seconds=i%60,h+=H(i/60),b.minutes=h%60,g+=H(h/60),b.hours=g%24,f+=H(g/24),f+=e*7,b.days=f%30,d+=H(f/30),b.months=d%12,c+=H(d/12),b.years=c}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(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function N(a){return D[a]?"'+("+D[a]+")+'":a.replace(n,"").replace(/\\?'/g,"\\'")}function O(a){return c.longDateFormat[a]||a}function P(a){var b="var a,b;return '"+a.replace(l,N)+"';",c=Function;return new c("t","v","o","p","m",b)}function Q(a){return C[a]||(C[a]=P(a)),C[a]}function R(a,b){function d(d,e){return c[d].call?c[d](a,b):c[d][e]}while(m.test(b))b=b.replace(m,O);return C[b]||(C[b]=P(b)),C[b](a,d,c.ordinal,J,c.meridiem)}function S(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 T(a,b,d,e){var f;switch(a){case"M":case"MM":d[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(f=0;f<12;f++)if(c.monthsParse[f].test(b)){d[1]=f;break}break;case"D":case"DD":case"DDD":case"DDDD":d[2]=~~b;break;case"YY":b=~~b,d[0]=b+(b>70?1900:2e3);break;case"YYYY":d[0]=~~Math.abs(b);break;case"a":case"A":e.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":d[3]=~~b;break;case"m":case"mm":d[4]=~~b;break;case"s":case"ss":d[5]=~~b;break;case"S":case"SS":case"SSS":d[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":e.isUTC=!0,f=(b+"").match(z),f&&f[1]&&(e.tzh=~~f[1]),f&&f[2]&&(e.tzm=~~f[2]),f&&f[0]==="+"&&(e.tzh=-e.tzh,e.tzm=-e.tzm)}}function U(b,c){var d=[0,0,1,0,0,0,0],e={tzh:0,tzm:0},f=c.match(l),g,h;for(g=0;g<f.length;g++)h=(S(f[g]).exec(b)||[])[0],b=b.replace(S(f[g]),""),T(f[g],h,d,e);return e.isPm&&d[3]<12&&(d[3]+=12),e.isPm===!1&&d[3]===12&&(d[3]=0),d[3]+=e.tzh,d[4]+=e.tzm,e.isUTC?new a(a.UTC.apply({},d)):M(d)}function V(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 W(a,b){var c,d=a.match(o)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=U(a,b[g]),e=R(new G(h),b[g]).match(o)||[],i=V(d,e),i<f&&(f=i,c=h);return c}function X(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)?U(b,c+" Z"):U(b,c)}return new a(b)}function Y(a,b,d,e){var f=c.relativeTime[a];return typeof f=="function"?f(b||1,!!d,a,e):f.replace(/%d/i,b||1)}function Z(a,b){var c=e(Math.abs(a)/1e3),d=e(c/60),f=e(d/60),g=e(f/24),h=e(g/365),i=c<45&&["s",c]||d===1&&["m"]||d<45&&["mm",d]||f===1&&["h"]||f<22&&["hh",f]||g===1&&["d"]||g<=25&&["dd",g]||g<=45&&["M"]||g<345&&["MM",e(g/30)]||h===1&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,Y.apply({},i)}function $(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 _(a){c.duration.fn[a]=function(){return this._data[a]}}function ab(a,b){c.duration.fn["as"+a]=function(){return+this/b}}var c,d="1.6.2",e=Math.round,f,g={},h="en",i=typeof module!="undefined",j="months|monthsShort|monthsParse|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{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:"t.year()",a:'m?m(t.hours(),t.minutes(),!1):t.hours()>11?"pm":"am"',A:'m?m(t.hours(),t.minutes(),!0):t.hours()>11?"PM":"AM"',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,h;return c.isMoment(d)?(f=new a(+d._d),h=d._isUTC):e?L(e)?f=W(d,e):f=U(d,e):(g=k.exec(d),f=d===b?new a:g?new a(+g[1]):d instanceof a?d:L(d)?M(d):typeof d=="string"?X(d):new a(d)),new G(f,h)},c.utc=function(b,d){return L(b)?new G(new a(a.UTC.apply({},b)),!0):d&&b?c(b+" +0000",d+" Z").utc():c(b&&w.exec(b)&&!u.exec(b)?b+"+0000":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;return e&&(b?f[b]=a:f.milliseconds=a),new I(f)},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,e,f=[];if(!a)return h;if(b){for(d=0;d<12;d++)f[d]=new RegExp("^"+b.months[d]+"|^"+b.monthsShort[d].replace(".",""),"i");b.monthsParse=b.monthsParse||f,g[a]=b}if(g[a]){for(d=0;d<j.length;d++)c[j[d]]=g[a][j[d]]||g.en[j[d]];h=a}else i&&(e=require("./lang/"+a),c.lang(a,e))},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:!1,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.isMoment=function(a){return a instanceof G},c.isDuration=function(a){return a instanceof I},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},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return R(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)).humanize(!b)},fromNow:function(a){return this.from(c(),a)},calendar:function(){var a=this.diff(c().sod(),"days",!0),b=c.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){var b=this.clone();switch(a){case"year":b.month(0);case"month":b.date(1);case"day":b.hours(0);case"hour":b.minutes(0);case"minute":b.seconds(0);case"second":b.milliseconds(0)}return b},endOf:function(a){return this.startOf(a).add(a+"s",1).subtract("milliseconds",1)},sod:function(){return this.startOf("day")},eod:function(){return this.endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return c.utc([this.year(),this.month()+1,0]).date()}};for(f=0;f<A.length;f++)$(A[f].toLowerCase(),A[f]);$("year","FullYear"),c.duration.fn=I.prototype={weeks:function(){return H(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,d=c.relativeTime,e=Z(b,!a);return a&&(e=(b<=0?d.past:d.future).replace(/%s/i,e)),e}};for(f in B)B.hasOwnProperty(f)&&(ab(f,B[f]),_(f.toLowerCase()));ab("Weeks",6048e5),i&&(module.exports=c),typeof window!="undefined"&&typeof ender=="undefined"&&(window.moment=c),typeof define=="function"&&define.amd&&define("moment",[],function(){return c})})(Date);
\ No newline at end of file
+(function(a,b){function G(a,b){this._d=a,this._isUTC=!!b}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}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){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function O(a){return D[a]?"'+("+D[a]+")+'":a.replace(n,"").replace(/\\?'/g,"\\'")}function P(a){return c.longDateFormat[a]||a}function Q(a){var b="var a,b;return '"+a.replace(l,O)+"';",c=Function;return new c("t","v","o","p","m",b)}function R(a){return C[a]||(C[a]=Q(a)),C[a]}function S(a,b){function d(d,e){return c[d].call?c[d](a,b):c[d][e]}while(m.test(b))b=b.replace(m,P);return C[b]||(C[b]=Q(b)),C[b](a,d,c.ordinal,J,c.meridiem)}function T(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 U(a,b,d,e){var f;switch(a){case"M":case"MM":d[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(f=0;f<12;f++)if(c.monthsParse[f].test(b)){d[1]=f;break}break;case"D":case"DD":case"DDD":case"DDDD":d[2]=~~b;break;case"YY":b=~~b,d[0]=b+(b>70?1900:2e3);break;case"YYYY":d[0]=~~Math.abs(b);break;case"a":case"A":e.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":d[3]=~~b;break;case"m":case"mm":d[4]=~~b;break;case"s":case"ss":d[5]=~~b;break;case"S":case"SS":case"SSS":d[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":e.isUTC=!0,f=(b+"").match(z),f&&f[1]&&(e.tzh=~~f[1]),f&&f[2]&&(e.tzm=~~f[2]),f&&f[0]==="+"&&(e.tzh=-e.tzh,e.tzm=-e.tzm)}}function V(b,c){var d=[0,0,1,0,0,0,0],e={tzh:0,tzm:0},f=c.match(l),g,h;for(g=0;g<f.length;g++)h=(T(f[g]).exec(b)||[])[0],b=b.replace(T(f[g]),""),U(f[g],h,d,e);return e.isPm&&d[3]<12&&(d[3]+=12),e.isPm===!1&&d[3]===12&&(d[3]=0),d[3]+=e.tzh,d[4]+=e.tzm,e.isUTC?new a(a.UTC.apply({},d)):N(d)}function W(a,b){var c,d=a.match(o)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=V(a,b[g]),e=S(new G(h),b[g]).match(o)||[],i=M(d,e),i<f&&(f=i,c=h);return c}function X(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)?V(b,c+" Z"):V(b,c)}return new a(b)}function Y(a,b,d,e){var f=c.relativeTime[a];return typeof f=="function"?f(b||1,!!d,a,e):f.replace(/%d/i,b||1)}function Z(a,b){var c=e(Math.abs(a)/1e3),d=e(c/60),f=e(d/60),g=e(f/24),h=e(g/365),i=c<45&&["s",c]||d===1&&["m"]||d<45&&["mm",d]||f===1&&["h"]||f<22&&["hh",f]||g===1&&["d"]||g<=25&&["dd",g]||g<=45&&["M"]||g<345&&["MM",e(g/30)]||h===1&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,Y.apply({},i)}function $(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 _(a){c.duration.fn[a]=function(){return this._data[a]}}function ab(a,b){c.duration.fn["as"+a]=function(){return+this/b}}var c,d="1.6.2",e=Math.round,f,g={},h="en",i=typeof module!="undefined",j="months|monthsShort|monthsParse|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{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:"t.year()",a:'m?m(t.hours(),t.minutes(),!1):t.hours()>11?"pm":"am"',A:'m?m(t.hours(),t.minutes(),!0):t.hours()>11?"PM":"AM"',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,h;return c.isMoment(d)?(f=new a(+d._d),h=d._isUTC):e?L(e)?f=W(d,e):f=V(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"?X(d):new a(d)),new G(f,h)},c.utc=function(b,d){return L(b)?new G(new a(a.UTC.apply({},b)),!0):d&&b?c(b+" +0000",d+" Z").utc():c(b&&w.exec(b)&&!u.exec(b)?b+"+0000":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;return e&&(b?f[b]=a:f.milliseconds=a),new H(f)},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,e,f=[];if(!a)return h;if(b){for(d=0;d<12;d++)f[d]=new RegExp("^"+b.months[d]+"|^"+b.monthsShort[d].replace(".",""),"i");b.monthsParse=b.monthsParse||f,g[a]=b}if(g[a]){for(d=0;d<j.length;d++)c[j[d]]=g[a][j[d]]||g.en[j[d]];h=a}else i&&(e=require("./lang/"+a),c.lang(a,e))},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:!1,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.isMoment=function(a){return a instanceof G},c.isDuration=function(a){return a instanceof H},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},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return S(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)).humanize(!b)},fromNow:function(a){return this.from(c(),a)},calendar:function(){var a=this.diff(c().sod(),"days",!0),b=c.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){var b=this.clone();switch(a){case"year":b.month(0);case"month":b.date(1);case"day":b.hours(0);case"hour":b.minutes(0);case"minute":b.seconds(0);case"second":b.milliseconds(0)}return b},endOf:function(a){return this.startOf(a).add(a+"s",1).subtract("milliseconds",1)},sod:function(){return this.startOf("day")},eod:function(){return this.endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return c.utc([this.year(),this.month()+1,0]).date()}};for(f=0;f<A.length;f++)$(A[f].toLowerCase(),A[f]);$("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,d=c.relativeTime,e=Z(b,!a);return a&&(e=(b<=0?d.past:d.future).replace(/%s/i,e)),e}};for(f in B)B.hasOwnProperty(f)&&(ab(f,B[f]),_(f.toLowerCase()));ab("Weeks",6048e5),i&&(module.exports=c),typeof window!="undefined"&&typeof ender=="undefined"&&(window.moment=c),typeof define=="function"&&define.amd&&define("moment",[],function(){return c})})(Date);
\ No newline at end of file
index 7b7e58bbb93592625273ec97acc09baf79b81a5d..6dbbfefeeebfc9db74a8c9a47116f8c6a35a712e 100644 (file)
@@ -8,11 +8,11 @@
         this._d = a, this._isUTC = !!b;
     }
     function H(a) {
-        return a < 0 ? Math.ceil(a) : Math.floor(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;
     }
     function I(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 += H(j / 1e3), b.seconds = i % 60, h += H(i / 60), b.minutes = h % 60, g += H(h / 60), b.hours = g % 24, f += H(g / 24), f += e * 7, b.days = f % 30, d += H(f / 30), b.months = d % 12, c += H(d / 12), b.years = c;
+        return a < 0 ? Math.ceil(a) : Math.floor(a);
     }
     function J(a, b) {
         var c = a + "";
     function L(a) {
         return Object.prototype.toString.call(a) === "[object Array]";
     }
-    function M(b) {
+    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) {
         return new a(b[0], b[1] || 0, b[2] || 1, b[3] || 0, b[4] || 0, b[5] || 0, b[6] || 0);
     }
-    function N(a) {
+    function O(a) {
         return D[a] ? "'+(" + D[a] + ")+'" : a.replace(n, "").replace(/\\?'/g, "\\'");
     }
-    function O(a) {
+    function P(a) {
         return c.longDateFormat[a] || a;
     }
-    function P(a) {
-        var b = "var a,b;return '" + a.replace(l, N) + "';", c = Function;
+    function Q(a) {
+        var b = "var a,b;return '" + a.replace(l, O) + "';", c = Function;
         return new c("t", "v", "o", "p", "m", b);
     }
-    function Q(a) {
-        return C[a] || (C[a] = P(a)), C[a];
+    function R(a) {
+        return C[a] || (C[a] = Q(a)), C[a];
     }
-    function R(a, b) {
+    function S(a, b) {
         function d(d, e) {
             return c[d].call ? c[d](a, b) : c[d][e];
         }
-        while (m.test(b)) b = b.replace(m, O);
-        return C[b] || (C[b] = P(b)), C[b](a, d, c.ordinal, J, c.meridiem);
+        while (m.test(b)) b = b.replace(m, P);
+        return C[b] || (C[b] = Q(b)), C[b](a, d, c.ordinal, J, c.meridiem);
     }
-    function S(a) {
+    function T(a) {
         switch (a) {
           case "DDDD":
             return r;
@@ -92,7 +97,7 @@
             return new RegExp(a.replace("\\", ""));
         }
     }
-    function T(a, b, d, e) {
+    function U(a, b, d, e) {
         var f;
         switch (a) {
           case "M":
             e.isUTC = !0, f = (b + "").match(z), f && f[1] && (e.tzh = ~~f[1]), f && f[2] && (e.tzm = ~~f[2]), f && f[0] === "+" && (e.tzh = -e.tzh, e.tzm = -e.tzm);
         }
     }
-    function U(b, c) {
+    function V(b, c) {
         var d = [ 0, 0, 1, 0, 0, 0, 0 ], e = {
             tzh: 0,
             tzm: 0
         }, f = c.match(l), g, h;
-        for (g = 0; g < f.length; g++) h = (S(f[g]).exec(b) || [])[0], b = b.replace(S(f[g]), ""), T(f[g], h, d, e);
-        return e.isPm && d[3] < 12 && (d[3] += 12), e.isPm === !1 && d[3] === 12 && (d[3] = 0), d[3] += e.tzh, d[4] += e.tzm, e.isUTC ? new a(a.UTC.apply({}, d)) : M(d);
-    }
-    function V(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;
+        for (g = 0; g < f.length; g++) h = (T(f[g]).exec(b) || [])[0], b = b.replace(T(f[g]), ""), U(f[g], h, d, e);
+        return e.isPm && d[3] < 12 && (d[3] += 12), e.isPm === !1 && d[3] === 12 && (d[3] = 0), d[3] += e.tzh, d[4] += e.tzm, e.isUTC ? new a(a.UTC.apply({}, d)) : N(d);
     }
     function W(a, b) {
         var c, d = a.match(o) || [], e, f = 99, g, h, i;
-        for (g = 0; g < b.length; g++) h = U(a, b[g]), e = R(new G(h), b[g]).match(o) || [], i = V(d, e), i < f && (f = i, c = h);
+        for (g = 0; g < b.length; g++) h = V(a, b[g]), e = S(new G(h), b[g]).match(o) || [], i = M(d, e), i < f && (f = i, c = h);
         return c;
     }
     function X(b) {
                 c += y[d][0];
                 break;
             }
-            return u.exec(b) ? U(b, c + " Z") : U(b, c);
+            return u.exec(b) ? V(b, c + " Z") : V(b, c);
         }
         return new a(b);
     }
     D.DDDD = "p(" + D.DDD + ",3)", c = function(d, e) {
         if (d === null || d === "") return null;
         var f, g, h;
-        return c.isMoment(d) ? (f = new a(+d._d), h = d._isUTC) : e ? L(e) ? f = W(d, e) : f = U(d, e) : (g = k.exec(d), f = d === b ? new a : g ? new a(+g[1]) : d instanceof a ? d : L(d) ? M(d) : typeof d == "string" ? X(d) : new a(d)), new G(f, h);
+        return c.isMoment(d) ? (f = new a(+d._d), h = d._isUTC) : e ? L(e) ? f = W(d, e) : f = V(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" ? X(d) : new a(d)), new G(f, h);
     }, c.utc = function(b, d) {
         return L(b) ? new G(new a(a.UTC.apply({}, b)), !0) : d && b ? c(b + " +0000", d + " Z").utc() : c(b && w.exec(b) && !u.exec(b) ? b + "+0000" : 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;
-        return e && (b ? f[b] = a : f.milliseconds = a), new I(f);
+        return e && (b ? f[b] = a : f.milliseconds = a), new H(f);
     }, 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) {
     }), c.isMoment = function(a) {
         return a instanceof G;
     }, c.isDuration = function(a) {
-        return a instanceof I;
+        return a instanceof H;
     }, c.fn = G.prototype = {
         clone: function() {
             return c(this);
             return this._isUTC = !1, this;
         },
         format: function(a) {
-            return R(this, a ? a : c.defaultFormat);
+            return S(this, a ? a : c.defaultFormat);
         },
         add: function(a, b) {
             var d = b ? c.duration(+b, a) : c.duration(a);
         }
     };
     for (f = 0; f < A.length; f++) $(A[f].toLowerCase(), A[f]);
-    $("year", "FullYear"), c.duration.fn = I.prototype = {
+    $("year", "FullYear"), c.duration.fn = H.prototype = {
         weeks: function() {
-            return H(this.days() / 7);
+            return I(this.days() / 7);
         },
         valueOf: function() {
             return this._milliseconds + this._days * 864e5 + this._months * 2592e6;
index 48ff5e0facd3c6512259c7d7545eed073dc5931a..b4c4b550b85cd61c37b8184f6b80aa39723c482e 100644 (file)
--- a/moment.js
+++ b/moment.js
@@ -6,6 +6,10 @@
 
 (function (Date, undefined) {
 
+    /************************************
+        Constants
+    ************************************/
+
     var moment,
         VERSION = "1.6.2",
         round = Math.round, i,
 
         // format function strings
         formatFunctions = {},
+
+        /*
+         * This uses new Function() to create an inlined formatting function.
+         * Results are a 3x speed boost
+         * http://jsperf.com/momentjs-cached-format-functions
+         *
+         * These strings are appended into a function using replaceFormatTokens and makeFormatFunction
+         */
         formatFunctionStrings = {
             // a = placeholder
             // b = placeholder
             // t = the current moment being formatted
             // v = getValueAtKey function
-            // o = ordinal
-            // p = pad
-            // m = meridiem
+            // o = moment.ordinal function
+            // p = leftZeroFill function
+            // m = moment.meridiem value or function
             M    : '(a=t.month()+1)',
             MMM  : 'v("monthsShort",t.month())',
             MMMM : 'v("months",t.month())',
     }
     formatFunctionStrings.DDDD = 'p(' + formatFunctionStrings.DDD + ',3)';
 
+
+    /************************************
+        Constructors
+    ************************************/
+
+
     // Moment prototype object
     function Moment(date, isUTC) {
         this._d = date;
         this._isUTC = !!isUTC;
     }
 
-    function absRound(number) {
-        if (number < 0) {
-            return Math.ceil(number);
-        } else {
-            return Math.floor(number);
-        }
-    }
-
     // Duration Constructor
     function Duration(duration) {
         var data = this._data = {},
         data.years = years;
     }
 
+
+    /************************************
+        Helpers
+    ************************************/
+
+
+    function absRound(number) {
+        if (number < 0) {
+            return Math.ceil(number);
+        } else {
+            return Math.floor(number);
+        }
+    }
+
     // left zero fill a number
     // see http://jsperf.com/left-zero-filling for performance comparison
     function leftZeroFill(number, targetLength) {
         return Object.prototype.toString.call(input) === '[object Array]';
     }
 
+    // compare two arrays, return the number of differences
+    function compareArrays(array1, array2) {
+        var len = Math.min(array1.length, array2.length),
+            lengthDiff = Math.abs(array1.length - array2.length),
+            diffs = 0,
+            i;
+        for (i = 0; i < len; i++) {
+            if (~~array1[i] !== ~~array2[i]) {
+                diffs++;
+            }
+        }
+        return diffs + lengthDiff;
+    }
+
     // convert an array to a date.
     // the array should mirror the parameters below
     // note: all values past the year are optional and will default to the lowest possible value.
     function dateFromArray(input) {
         return new Date(input[0], input[1] || 0, input[2] || 1, input[3] || 0, input[4] || 0, input[5] || 0, input[6] || 0);
     }
-    
+
+
+    /************************************
+        Formatting
+    ************************************/
+
+
+    // helper for building inline formatting functions
     function replaceFormatTokens(token) {
         return formatFunctionStrings[token] ? 
             ("'+(" + formatFunctionStrings[token] + ")+'") :
             token.replace(formattingRemoveEscapes, "").replace(/\\?'/g, "\\'");
     }
 
+    // helper for recursing long date formatting tokens
     function replaceLongDateFormatTokens(input) {
         return moment.longDateFormat[input] || input;
     }
         var output = "var a,b;return '" +
             format.replace(formattingTokens, replaceFormatTokens) + "';",
             Fn = Function; // get around jshint
-        // a = placeholder
-        // b = placeholder
         // t = the current moment being formatted
         // v = getValueAtKey function
-        // o = ordinal
-        // p = pad
-        // m = meridiem
+        // o = moment.ordinal function
+        // p = leftZeroFill function
+        // m = moment.meridiem value or function
         return new Fn('t', 'v', 'o', 'p', 'm', output);
     }
 
         return formatFunctions[format](m, getValueFromArray, moment.ordinal, leftZeroFill, moment.meridiem);
     }
 
+
+    /************************************
+        Parsing
+    ************************************/
+
+
     // get the regex to find the next token
     function getParseRegexForToken(token) {
         switch (token) {
         return config.isUTC ? new Date(Date.UTC.apply({}, datePartArray)) : dateFromArray(datePartArray);
     }
 
-    // compare two arrays, return the number of differences
-    function compareArrays(array1, array2) {
-        var len = Math.min(array1.length, array2.length),
-            lengthDiff = Math.abs(array1.length - array2.length),
-            diffs = 0,
-            i;
-        for (i = 0; i < len; i++) {
-            if (~~array1[i] !== ~~array2[i]) {
-                diffs++;
-            }
-        }
-        return diffs + lengthDiff;
-    }
-
     // date from string and array of format strings
     function makeDateFromStringAndArray(string, formats) {
         var output,
         return new Date(string);
     }
 
+
+    /************************************
+        Relative Time
+    ************************************/
+
+
     // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
     function substituteTimeAgo(string, number, withoutSuffix, isFuture) {
         var rt = moment.relativeTime[string];
         return substituteTimeAgo.apply({}, args);
     }
 
+
+    /************************************
+        Top Level Functions
+    ************************************/
+
+
     moment = function (input, format) {
         if (input === null || input === '') {
             return null;
         return obj instanceof Duration;
     };
 
-    // shortcut for prototype
+
+    /************************************
+        Moment Prototype
+    ************************************/
+
+
     moment.fn = Moment.prototype = {
 
         clone : function () {
     // add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear')
     makeGetterAndSetter('year', 'FullYear');
 
+
+    /************************************
+        Duration Prototype
+    ************************************/
+
+
     moment.duration.fn = Duration.prototype = {
         weeks : function () {
             return absRound(this.days() / 7);
 
     makeDurationAsGetter('Weeks', 6048e5);
 
+
+    /************************************
+        Exposing Moment
+    ************************************/
+
+
     // CommonJS module is defined
     if (hasModule) {
         module.exports = moment;