flashgrid-ext 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abe606333a012aca2e4e472f34d231f352ffccb3
4
- data.tar.gz: e9d2ca543c70a4ccee217049147dcb5088c2fe99
3
+ metadata.gz: 51599e11b68a7eb4f5e0ab8c15833f79b4d3ac91
4
+ data.tar.gz: b5d7e5d6b8c0cf3cb8e6d43de69f01c4275d21f0
5
5
  SHA512:
6
- metadata.gz: ba212b919a042071782e919be0a611be92a035b4eee0995fcc0b8f085c34a1feca7f9bf677f1196dd53403b2a32ae299527d2b67ea5caa2ffbbc3a5fa864361b
7
- data.tar.gz: 03c3936c256f95becb4cd039d985eaff17f71bd492eb037a100114c1e7f33970d518e69e0e0a41bf1ca1ac1883ffd5ef55d6ff508dd98e9d9ea29b83c3a4b096
6
+ metadata.gz: 9b3457406ff51c0f2723bd94342c65254bcc565bb726ad85ebcaea0a97c66929f3e642858dae24ab37d13bc57cb05030e02320e9c2916002974946fc38e58b06
7
+ data.tar.gz: 905f684cd553fa25eb38ad116b545007e3581b1b142bc07187e39d5c5101dcbfb33578737e991704606520100b4622b2459d335680034c4dc20dac2e38a70a86
@@ -1,5 +1,5 @@
1
1
  module Flashgrid
2
2
  module Ext
3
- VERSION = "2.1.2"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -863,7 +863,9 @@
863
863
  yMin;
864
864
  helpers.each(this.datasets, function(dataset){
865
865
  dataCollection = dataset.points || dataset.bars || dataset.segments;
866
- Elements.push(dataCollection[dataIndex]);
866
+ if (dataCollection[dataIndex]){
867
+ Elements.push(dataCollection[dataIndex]);
868
+ }
867
869
  });
868
870
 
869
871
  helpers.each(Elements, function(element) {
@@ -1032,24 +1034,27 @@
1032
1034
 
1033
1035
 
1034
1036
  Chart.Point = Chart.Element.extend({
1037
+ display : true,
1035
1038
  inRange : function(chartX,chartY){
1036
1039
  var hitDetectionRange = this.hitDetectionRadius + this.radius;
1037
1040
  return ((Math.pow(chartX-this.x, 2)+Math.pow(chartY-this.y, 2)) < Math.pow(hitDetectionRange,2));
1038
1041
  },
1039
1042
  draw : function(){
1040
- var ctx = this.ctx;
1041
- ctx.beginPath();
1043
+ if (this.display){
1044
+ var ctx = this.ctx;
1045
+ ctx.beginPath();
1042
1046
 
1043
- ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);
1044
- ctx.closePath();
1047
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);
1048
+ ctx.closePath();
1045
1049
 
1046
- ctx.strokeStyle = this.strokeColor;
1047
- ctx.lineWidth = this.strokeWidth;
1050
+ ctx.strokeStyle = this.strokeColor;
1051
+ ctx.lineWidth = this.strokeWidth;
1048
1052
 
1049
- ctx.fillStyle = this.fillColor;
1053
+ ctx.fillStyle = this.fillColor;
1050
1054
 
1051
- ctx.fill();
1052
- ctx.stroke();
1055
+ ctx.fill();
1056
+ ctx.stroke();
1057
+ }
1053
1058
 
1054
1059
 
1055
1060
 
@@ -1861,6 +1866,8 @@
1861
1866
  define(function(){
1862
1867
  return Chart;
1863
1868
  });
1869
+ } else if (typeof module === 'object' && module.exports) {
1870
+ module.exports = Chart;
1864
1871
  }
1865
1872
 
1866
1873
  root.Chart = Chart;
@@ -1982,6 +1989,7 @@
1982
1989
  datasetObject.bars.push(new this.BarClass({
1983
1990
  value : dataPoint,
1984
1991
  label : data.labels[index],
1992
+ datasetLabel: dataset.label,
1985
1993
  strokeColor : dataset.strokeColor,
1986
1994
  fillColor : dataset.fillColor,
1987
1995
  highlightFill : dataset.highlightFill || dataset.fillColor,
@@ -2409,6 +2417,7 @@
2409
2417
  this.PointClass = Chart.Point.extend({
2410
2418
  strokeWidth : this.options.pointDotStrokeWidth,
2411
2419
  radius : this.options.pointDotRadius,
2420
+ display : this.options.pointDot,
2412
2421
  hitDetectionRadius : this.options.pointHitDetectionRadius,
2413
2422
  ctx : this.chart.ctx,
2414
2423
  inRange : function(mouseX){
@@ -2457,6 +2466,7 @@
2457
2466
  label : data.labels[index],
2458
2467
  // x: this.scale.calculateX(index),
2459
2468
  // y: this.scale.endPoint,
2469
+ datasetLabel: dataset.label,
2460
2470
  strokeColor : dataset.pointStrokeColor,
2461
2471
  fillColor : dataset.pointColor,
2462
2472
  highlightFill : dataset.pointHighlightFill || dataset.pointColor,
@@ -3013,6 +3023,7 @@
3013
3023
  this.PointClass = Chart.Point.extend({
3014
3024
  strokeWidth : this.options.pointDotStrokeWidth,
3015
3025
  radius : this.options.pointDotRadius,
3026
+ display : this.options.pointDot,
3016
3027
  hitDetectionRadius : this.options.pointHitDetectionRadius,
3017
3028
  ctx : this.chart.ctx
3018
3029
  });
@@ -3044,6 +3055,7 @@
3044
3055
  var datasetObject = {
3045
3056
  label: dataset.label || null,
3046
3057
  fillColor : dataset.fillColor,
3058
+ datasetLabel: dataset.label,
3047
3059
  strokeColor : dataset.strokeColor,
3048
3060
  pointColor : dataset.pointColor,
3049
3061
  pointStrokeColor : dataset.pointStrokeColor,
@@ -3217,6 +3229,7 @@
3217
3229
  this.eachPoints(function(point){
3218
3230
  point.save();
3219
3231
  });
3232
+ this.reflow();
3220
3233
  this.render();
3221
3234
  },
3222
3235
  reflow: function(){
@@ -1 +1,2604 @@
1
- (function(a){function b(a,b,c){switch(arguments.length){case 2:return null!=a?a:b;case 3:return null!=a?a:null!=b?b:c;default:throw new Error("Implement me")}}function c(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function d(a,b){function c(){mb.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+a)}var d=!0;return j(function(){return d&&(c(),d=!1),b.apply(this,arguments)},b)}function e(a,b){return function(c){return m(a.call(this,c),b)}}function f(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function g(){}function h(a){z(a),j(this,a)}function i(a){var b=s(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;this._milliseconds=+k+1e3*j+6e4*i+36e5*h,this._days=+g+7*f,this._months=+e+3*d+12*c,this._data={},this._bubble()}function j(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function k(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&Ab.hasOwnProperty(b)&&(c[b]=a[b]);return c}function l(a){return 0>a?Math.ceil(a):Math.floor(a)}function m(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function n(a,b,c,d){var e=b._milliseconds,f=b._days,g=b._months;d=null==d?!0:d,e&&a._d.setTime(+a._d+e*c),f&&hb(a,"Date",gb(a,"Date")+f*c),g&&fb(a,gb(a,"Month")+g*c),d&&mb.updateOffset(a,f||g)}function o(a){return"[object Array]"===Object.prototype.toString.call(a)}function p(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function q(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&u(a[d])!==u(b[d]))&&g++;return g+f}function r(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=bc[a]||cc[b]||b}return a}function s(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=r(c),b&&(d[b]=a[c]));return d}function t(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}mb[b]=function(e,f){var g,h,i=mb.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=mb().utc().set(d,a);return i.call(mb.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function u(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function v(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function w(a,b,c){return bb(mb([a,11,31+b-c]),b,c).week}function x(a){return y(a)?366:365}function y(a){return a%4===0&&a%100!==0||a%400===0}function z(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[tb]<0||a._a[tb]>11?tb:a._a[ub]<1||a._a[ub]>v(a._a[sb],a._a[tb])?ub:a._a[vb]<0||a._a[vb]>23?vb:a._a[wb]<0||a._a[wb]>59?wb:a._a[xb]<0||a._a[xb]>59?xb:a._a[yb]<0||a._a[yb]>999?yb:-1,a._pf._overflowDayOfYear&&(sb>b||b>ub)&&(b=ub),a._pf.overflow=b)}function A(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function B(a){return a?a.toLowerCase().replace("_","-"):a}function C(a,b){return b._isUTC?mb(a).zone(b._offset||0):mb(a).local()}function D(a,b){return b.abbr=a,zb[a]||(zb[a]=new g),zb[a].set(b),zb[a]}function E(a){delete zb[a]}function F(a){var b,c,d,e,f=0,g=function(a){if(!zb[a]&&Bb)try{require("./lang/"+a)}catch(b){}return zb[a]};if(!a)return mb.fn._lang;if(!o(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=B(a[f]).split("-"),b=e.length,d=B(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&q(e,d,!0)>=b-1)break;b--}f++}return mb.fn._lang}function G(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function H(a){var b,c,d=a.match(Fb);for(b=0,c=d.length;c>b;b++)d[b]=hc[d[b]]?hc[d[b]]:G(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function I(a,b){return a.isValid()?(b=J(b,a.lang()),dc[b]||(dc[b]=H(b)),dc[b](a)):a.lang().invalidDate()}function J(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Gb.lastIndex=0;d>=0&&Gb.test(a);)a=a.replace(Gb,c),Gb.lastIndex=0,d-=1;return a}function K(a,b){var c,d=b._strict;switch(a){case"Q":return Rb;case"DDDD":return Tb;case"YYYY":case"GGGG":case"gggg":return d?Ub:Jb;case"Y":case"G":case"g":return Wb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Vb:Kb;case"S":if(d)return Rb;case"SS":if(d)return Sb;case"SSS":if(d)return Tb;case"DDD":return Ib;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Mb;case"a":case"A":return F(b._l)._meridiemParse;case"X":return Pb;case"Z":case"ZZ":return Nb;case"T":return Ob;case"SSSS":return Lb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Sb:Hb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Hb;case"Do":return Qb;default:return c=new RegExp(T(S(a.replace("\\","")),"i"))}}function L(a){a=a||"";var b=a.match(Nb)||[],c=b[b.length-1]||[],d=(c+"").match(_b)||["-",0,0],e=+(60*d[1])+u(d[2]);return"+"===d[0]?-e:e}function M(a,b,c){var d,e=c._a;switch(a){case"Q":null!=b&&(e[tb]=3*(u(b)-1));break;case"M":case"MM":null!=b&&(e[tb]=u(b)-1);break;case"MMM":case"MMMM":d=F(c._l).monthsParse(b),null!=d?e[tb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[ub]=u(b));break;case"Do":null!=b&&(e[ub]=u(parseInt(b,10)));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=u(b));break;case"YY":e[sb]=mb.parseTwoDigitYear(b);break;case"YYYY":case"YYYYY":case"YYYYYY":e[sb]=u(b);break;case"a":case"A":c._isPm=F(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[vb]=u(b);break;case"m":case"mm":e[wb]=u(b);break;case"s":case"ss":e[xb]=u(b);break;case"S":case"SS":case"SSS":case"SSSS":e[yb]=u(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=L(b);break;case"dd":case"ddd":case"dddd":d=F(c._l).weekdaysParse(b),null!=d?(c._w=c._w||{},c._w.d=d):c._pf.invalidWeekday=b;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":a=a.substr(0,1);case"gggg":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=u(b));break;case"gg":case"GG":c._w=c._w||{},c._w[a]=mb.parseTwoDigitYear(b)}}function N(a){var c,d,e,f,g,h,i,j;c=a._w,null!=c.GG||null!=c.W||null!=c.E?(g=1,h=4,d=b(c.GG,a._a[sb],bb(mb(),1,4).year),e=b(c.W,1),f=b(c.E,1)):(j=F(a._l),g=j._week.dow,h=j._week.doy,d=b(c.gg,a._a[sb],bb(mb(),g,h).year),e=b(c.w,1),null!=c.d?(f=c.d,g>f&&++e):f=null!=c.e?c.e+g:g),i=cb(d,e,f,h,g),a._a[sb]=i.year,a._dayOfYear=i.dayOfYear}function O(a){var c,d,e,f,g=[];if(!a._d){for(e=Q(a),a._w&&null==a._a[ub]&&null==a._a[tb]&&N(a),a._dayOfYear&&(f=b(a._a[sb],e[sb]),a._dayOfYear>x(f)&&(a._pf._overflowDayOfYear=!0),d=Z(f,0,a._dayOfYear),a._a[tb]=d.getUTCMonth(),a._a[ub]=d.getUTCDate()),c=0;3>c&&null==a._a[c];++c)a._a[c]=g[c]=e[c];for(;7>c;c++)a._a[c]=g[c]=null==a._a[c]?2===c?1:0:a._a[c];a._d=(a._useUTC?Z:Y).apply(null,g),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()+a._tzm)}}function P(a){var b;a._d||(b=s(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],O(a))}function Q(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function R(a){if(a._f===mb.ISO_8601)return void V(a);a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=F(a._l),h=""+a._i,i=h.length,j=0;for(d=J(a._f,g).match(Fb)||[],b=0;b<d.length;b++)e=d[b],c=(h.match(K(e,a))||[])[0],c&&(f=h.substr(0,h.indexOf(c)),f.length>0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),hc[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),M(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[vb]<12&&(a._a[vb]+=12),a._isPm===!1&&12===a._a[vb]&&(a._a[vb]=0),O(a),z(a)}function S(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function T(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function U(a){var b,d,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;f<a._f.length;f++)g=0,b=j({},a),b._pf=c(),b._f=a._f[f],R(b),A(b)&&(g+=b._pf.charsLeftOver,g+=10*b._pf.unusedTokens.length,b._pf.score=g,(null==e||e>g)&&(e=g,d=b));j(a,d||b)}function V(a){var b,c,d=a._i,e=Xb.exec(d);if(e){for(a._pf.iso=!0,b=0,c=Zb.length;c>b;b++)if(Zb[b][1].exec(d)){a._f=Zb[b][0]+(e[6]||" ");break}for(b=0,c=$b.length;c>b;b++)if($b[b][1].exec(d)){a._f+=$b[b][0];break}d.match(Nb)&&(a._f+="Z"),R(a)}else a._isValid=!1}function W(a){V(a),a._isValid===!1&&(delete a._isValid,mb.createFromInputFallback(a))}function X(b){var c=b._i,d=Cb.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?W(b):o(c)?(b._a=c.slice(0),O(b)):p(c)?b._d=new Date(+c):"object"==typeof c?P(b):"number"==typeof c?b._d=new Date(c):mb.createFromInputFallback(b)}function Y(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function Z(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function $(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function _(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function ab(a,b,c){var d=rb(Math.abs(a)/1e3),e=rb(d/60),f=rb(e/60),g=rb(f/24),h=rb(g/365),i=d<ec.s&&["s",d]||1===e&&["m"]||e<ec.m&&["mm",e]||1===f&&["h"]||f<ec.h&&["hh",f]||1===g&&["d"]||g<=ec.dd&&["dd",g]||g<=ec.dm&&["M"]||g<ec.dy&&["MM",rb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,_.apply({},i)}function bb(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=mb(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function cb(a,b,c,d,e){var f,g,h=Z(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:x(a-1)+g}}function db(b){var c=b._i,d=b._f;return null===c||d===a&&""===c?mb.invalid({nullInput:!0}):("string"==typeof c&&(b._i=c=F().preparse(c)),mb.isMoment(c)?(b=k(c),b._d=new Date(+c._d)):d?o(d)?U(b):R(b):X(b),new h(b))}function eb(a,b){var c,d;if(1===b.length&&o(b[0])&&(b=b[0]),!b.length)return mb();for(c=b[0],d=1;d<b.length;++d)b[d][a](c)&&(c=b[d]);return c}function fb(a,b){var c;return"string"==typeof b&&(b=a.lang().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),v(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function gb(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function hb(a,b,c){return"Month"===b?fb(a,c):a._d["set"+(a._isUTC?"UTC":"")+b](c)}function ib(a,b){return function(c){return null!=c?(hb(this,a,c),mb.updateOffset(this,b),this):gb(this,a)}}function jb(a){mb.duration.fn[a]=function(){return this._data[a]}}function kb(a,b){mb.duration.fn["as"+a]=function(){return+this/b}}function lb(a){"undefined"==typeof ender&&(nb=qb.moment,qb.moment=a?d("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",mb):mb)}for(var mb,nb,ob,pb="2.7.0",qb="undefined"!=typeof global?global:this,rb=Math.round,sb=0,tb=1,ub=2,vb=3,wb=4,xb=5,yb=6,zb={},Ab={_isAMomentObject:null,_i:null,_f:null,_l:null,_strict:null,_tzm:null,_isUTC:null,_offset:null,_pf:null,_lang:null},Bb="undefined"!=typeof module&&module.exports,Cb=/^\/?Date\((\-?\d+)/i,Db=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Eb=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Fb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Gb=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,Hb=/\d\d?/,Ib=/\d{1,3}/,Jb=/\d{1,4}/,Kb=/[+\-]?\d{1,6}/,Lb=/\d+/,Mb=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Nb=/Z|[\+\-]\d\d:?\d\d/gi,Ob=/T/i,Pb=/[\+\-]?\d+(\.\d{1,3})?/,Qb=/\d{1,2}/,Rb=/\d/,Sb=/\d\d/,Tb=/\d{3}/,Ub=/\d{4}/,Vb=/[+-]?\d{6}/,Wb=/[+-]?\d+/,Xb=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Yb="YYYY-MM-DDTHH:mm:ssZ",Zb=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],$b=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],_b=/([\+\-]|\d\d)/gi,ac=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),bc={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},cc={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},dc={},ec={s:45,m:45,h:22,dd:25,dm:45,dy:345},fc="DDD w W M D d".split(" "),gc="M D H h m s w W".split(" "),hc={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return m(this.year()%100,2)},YYYY:function(){return m(this.year(),4)},YYYYY:function(){return m(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+m(Math.abs(a),6)},gg:function(){return m(this.weekYear()%100,2)},gggg:function(){return m(this.weekYear(),4)},ggggg:function(){return m(this.weekYear(),5)},GG:function(){return m(this.isoWeekYear()%100,2)},GGGG:function(){return m(this.isoWeekYear(),4)},GGGGG:function(){return m(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return u(this.milliseconds()/100)},SS:function(){return m(u(this.milliseconds()/10),2)},SSS:function(){return m(this.milliseconds(),3)},SSSS:function(){return m(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+m(u(a/60),2)+":"+m(u(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+m(u(a/60),2)+m(u(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},ic=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];fc.length;)ob=fc.pop(),hc[ob+"o"]=f(hc[ob],ob);for(;gc.length;)ob=gc.pop(),hc[ob+ob]=e(hc[ob],2);for(hc.DDDD=e(hc.DDD,3),j(g.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=mb.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=mb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,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"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_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"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return bb(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),mb=function(b,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=b,g._f=d,g._l=e,g._strict=f,g._isUTC=!1,g._pf=c(),db(g)},mb.suppressDeprecationWarnings=!1,mb.createFromInputFallback=d("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i)}),mb.min=function(){var a=[].slice.call(arguments,0);return eb("isBefore",a)},mb.max=function(){var a=[].slice.call(arguments,0);return eb("isAfter",a)},mb.utc=function(b,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=b,g._f=d,g._strict=f,g._pf=c(),db(g).utc()},mb.unix=function(a){return mb(1e3*a)},mb.duration=function(a,b){var c,d,e,f=a,g=null;return mb.isDuration(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(f={},b?f[b]=a:f.milliseconds=a):(g=Db.exec(a))?(c="-"===g[1]?-1:1,f={y:0,d:u(g[ub])*c,h:u(g[vb])*c,m:u(g[wb])*c,s:u(g[xb])*c,ms:u(g[yb])*c}):(g=Eb.exec(a))&&(c="-"===g[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},f={y:e(g[2]),M:e(g[3]),d:e(g[4]),h:e(g[5]),m:e(g[6]),s:e(g[7]),w:e(g[8])}),d=new i(f),mb.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},mb.version=pb,mb.defaultFormat=Yb,mb.ISO_8601=function(){},mb.momentProperties=Ab,mb.updateOffset=function(){},mb.relativeTimeThreshold=function(b,c){return ec[b]===a?!1:(ec[b]=c,!0)},mb.lang=function(a,b){var c;return a?(b?D(B(a),b):null===b?(E(a),a="en"):zb[a]||F(a),c=mb.duration.fn._lang=mb.fn._lang=F(a),c._abbr):mb.fn._lang._abbr},mb.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),F(a)},mb.isMoment=function(a){return a instanceof h||null!=a&&a.hasOwnProperty("_isAMomentObject")},mb.isDuration=function(a){return a instanceof i},ob=ic.length-1;ob>=0;--ob)t(ic[ob]);mb.normalizeUnits=function(a){return r(a)},mb.invalid=function(a){var b=mb.utc(0/0);return null!=a?j(b._pf,a):b._pf.userInvalidated=!0,b},mb.parseZone=function(){return mb.apply(null,arguments).parseZone()},mb.parseTwoDigitYear=function(a){return u(a)+(u(a)>68?1900:2e3)},j(mb.fn=h.prototype,{clone:function(){return mb(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=mb(this).utc();return 0<a.year()&&a.year()<=9999?I(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):I(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return A(this)},isDSTShifted:function(){return this._a?this.isValid()&&q(this._a,(this._isUTC?mb.utc(this._a):mb(this._a)).toArray())>0:!1},parsingFlags:function(){return j({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=I(this,a||mb.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a&&"string"==typeof b?mb.duration(isNaN(+b)?+a:+b,isNaN(+b)?b:a):"string"==typeof a?mb.duration(+b,a):mb.duration(a,b),n(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a&&"string"==typeof b?mb.duration(isNaN(+b)?+a:+b,isNaN(+b)?b:a):"string"==typeof a?mb.duration(+b,a):mb.duration(a,b),n(this,c,-1),this},diff:function(a,b,c){var d,e,f=C(a,this),g=6e4*(this.zone()-f.zone());return b=r(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-mb(this).startOf("month")-(f-mb(f).startOf("month")))/d,e-=6e4*(this.zone()-mb(this).startOf("month").zone()-(f.zone()-mb(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:l(e)},from:function(a,b){return mb.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(mb(),a)},calendar:function(a){var b=a||mb(),c=C(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.lang().calendar(e,this))},isLeapYear:function(){return y(this.year())},isDST:function(){return this.zone()<this.clone().month(0).zone()||this.zone()<this.clone().month(5).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=$(a,this.lang()),this.add({d:a-b})):b},month:ib("Month",!0),startOf:function(a){switch(a=r(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this},endOf:function(a){return a=r(a),this.startOf(a).add("isoWeek"===a?"week":a,1).subtract("ms",1)},isAfter:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)>+mb(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+mb(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+C(a,this).startOf(b)},min:d("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(a){return a=mb.apply(null,arguments),this>a?this:a}),max:d("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(a){return a=mb.apply(null,arguments),a>this?this:a}),zone:function(a,b){var c=this._offset||0;return null==a?this._isUTC?c:this._d.getTimezoneOffset():("string"==typeof a&&(a=L(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,c!==a&&(!b||this._changeInProgress?n(this,mb.duration(c-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,mb.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?mb(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return v(this.year(),this.month())},dayOfYear:function(a){var b=rb((mb(this).startOf("day")-mb(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)},weekYear:function(a){var b=bb(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=bb(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=bb(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return w(this.year(),1,4)},weeksInYear:function(){var a=this._lang._week;return w(this.year(),a.dow,a.doy)},get:function(a){return a=r(a),this[a]()},set:function(a,b){return a=r(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=F(b),this)}}),mb.fn.millisecond=mb.fn.milliseconds=ib("Milliseconds",!1),mb.fn.second=mb.fn.seconds=ib("Seconds",!1),mb.fn.minute=mb.fn.minutes=ib("Minutes",!1),mb.fn.hour=mb.fn.hours=ib("Hours",!0),mb.fn.date=ib("Date",!0),mb.fn.dates=d("dates accessor is deprecated. Use date instead.",ib("Date",!0)),mb.fn.year=ib("FullYear",!0),mb.fn.years=d("years accessor is deprecated. Use year instead.",ib("FullYear",!0)),mb.fn.days=mb.fn.day,mb.fn.months=mb.fn.month,mb.fn.weeks=mb.fn.week,mb.fn.isoWeeks=mb.fn.isoWeek,mb.fn.quarters=mb.fn.quarter,mb.fn.toJSON=mb.fn.toISOString,j(mb.duration.fn=i.prototype,{_bubble:function(){var a,b,c,d,e=this._milliseconds,f=this._days,g=this._months,h=this._data;h.milliseconds=e%1e3,a=l(e/1e3),h.seconds=a%60,b=l(a/60),h.minutes=b%60,c=l(b/60),h.hours=c%24,f+=l(c/24),h.days=f%30,g+=l(f/30),h.months=g%12,d=l(g/12),h.years=d},weeks:function(){return l(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*u(this._months/12)},humanize:function(a){var b=+this,c=ab(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},add:function(a,b){var c=mb.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=mb.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=r(a),this[a.toLowerCase()+"s"]()},as:function(a){return a=r(a),this["as"+a.charAt(0).toUpperCase()+a.slice(1)+"s"]()},lang:mb.fn.lang,toIsoString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}});for(ob in ac)ac.hasOwnProperty(ob)&&(kb(ob,ac[ob]),jb(ob.toLowerCase()));kb("Weeks",6048e5),mb.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},mb.lang("en",{ordinal:function(a){var b=a%10,c=1===u(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),Bb?module.exports=mb:"function"==typeof define&&define.amd?(define("moment",function(a,b,c){return c.config&&c.config()&&c.config().noGlobal===!0&&(qb.moment=nb),mb}),lb(!0)):lb()}).call(this);
1
+ (function (undefined) {
2
+
3
+ /************************************
4
+ Constants
5
+ ************************************/
6
+
7
+ var moment,
8
+ VERSION = "2.7.0",
9
+ // the global-scope this is NOT the global object in Node.js
10
+ globalScope = typeof global !== 'undefined' ? global : this,
11
+ oldGlobalMoment,
12
+ round = Math.round,
13
+ i,
14
+
15
+ YEAR = 0,
16
+ MONTH = 1,
17
+ DATE = 2,
18
+ HOUR = 3,
19
+ MINUTE = 4,
20
+ SECOND = 5,
21
+ MILLISECOND = 6,
22
+
23
+ // internal storage for language config files
24
+ languages = {},
25
+
26
+ // moment internal properties
27
+ momentProperties = {
28
+ _isAMomentObject: null,
29
+ _i : null,
30
+ _f : null,
31
+ _l : null,
32
+ _strict : null,
33
+ _tzm : null,
34
+ _isUTC : null,
35
+ _offset : null, // optional. Combine with _isUTC
36
+ _pf : null,
37
+ _lang : null // optional
38
+ },
39
+
40
+ // check for nodeJS
41
+ hasModule = (typeof module !== 'undefined' && module.exports),
42
+
43
+ // ASP.NET json date format regex
44
+ aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
45
+ aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,
46
+
47
+ // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
48
+ // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
49
+ isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
50
+
51
+ // format tokens
52
+ formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
53
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
54
+
55
+ // parsing token regexes
56
+ parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
57
+ parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999
58
+ parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999
59
+ parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
60
+ parseTokenDigits = /\d+/, // nonzero number of digits
61
+ parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
62
+ parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
63
+ parseTokenT = /T/i, // T (ISO separator)
64
+ parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
65
+ parseTokenOrdinal = /\d{1,2}/,
66
+
67
+ //strict parsing regexes
68
+ parseTokenOneDigit = /\d/, // 0 - 9
69
+ parseTokenTwoDigits = /\d\d/, // 00 - 99
70
+ parseTokenThreeDigits = /\d{3}/, // 000 - 999
71
+ parseTokenFourDigits = /\d{4}/, // 0000 - 9999
72
+ parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999
73
+ parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf
74
+
75
+ // iso 8601 regex
76
+ // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
77
+ isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
78
+
79
+ isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
80
+
81
+ isoDates = [
82
+ ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
83
+ ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
84
+ ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
85
+ ['GGGG-[W]WW', /\d{4}-W\d{2}/],
86
+ ['YYYY-DDD', /\d{4}-\d{3}/]
87
+ ],
88
+
89
+ // iso time formats and regexes
90
+ isoTimes = [
91
+ ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
92
+ ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
93
+ ['HH:mm', /(T| )\d\d:\d\d/],
94
+ ['HH', /(T| )\d\d/]
95
+ ],
96
+
97
+ // timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"]
98
+ parseTimezoneChunker = /([\+\-]|\d\d)/gi,
99
+
100
+ // getter and setter names
101
+ proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'),
102
+ unitMillisecondFactors = {
103
+ 'Milliseconds' : 1,
104
+ 'Seconds' : 1e3,
105
+ 'Minutes' : 6e4,
106
+ 'Hours' : 36e5,
107
+ 'Days' : 864e5,
108
+ 'Months' : 2592e6,
109
+ 'Years' : 31536e6
110
+ },
111
+
112
+ unitAliases = {
113
+ ms : 'millisecond',
114
+ s : 'second',
115
+ m : 'minute',
116
+ h : 'hour',
117
+ d : 'day',
118
+ D : 'date',
119
+ w : 'week',
120
+ W : 'isoWeek',
121
+ M : 'month',
122
+ Q : 'quarter',
123
+ y : 'year',
124
+ DDD : 'dayOfYear',
125
+ e : 'weekday',
126
+ E : 'isoWeekday',
127
+ gg: 'weekYear',
128
+ GG: 'isoWeekYear'
129
+ },
130
+
131
+ camelFunctions = {
132
+ dayofyear : 'dayOfYear',
133
+ isoweekday : 'isoWeekday',
134
+ isoweek : 'isoWeek',
135
+ weekyear : 'weekYear',
136
+ isoweekyear : 'isoWeekYear'
137
+ },
138
+
139
+ // format function strings
140
+ formatFunctions = {},
141
+
142
+ // default relative time thresholds
143
+ relativeTimeThresholds = {
144
+ s: 45, //seconds to minutes
145
+ m: 45, //minutes to hours
146
+ h: 22, //hours to days
147
+ dd: 25, //days to month (month == 1)
148
+ dm: 45, //days to months (months > 1)
149
+ dy: 345 //days to year
150
+ },
151
+
152
+ // tokens to ordinalize and pad
153
+ ordinalizeTokens = 'DDD w W M D d'.split(' '),
154
+ paddedTokens = 'M D H h m s w W'.split(' '),
155
+
156
+ formatTokenFunctions = {
157
+ M : function () {
158
+ return this.month() + 1;
159
+ },
160
+ MMM : function (format) {
161
+ return this.lang().monthsShort(this, format);
162
+ },
163
+ MMMM : function (format) {
164
+ return this.lang().months(this, format);
165
+ },
166
+ D : function () {
167
+ return this.date();
168
+ },
169
+ DDD : function () {
170
+ return this.dayOfYear();
171
+ },
172
+ d : function () {
173
+ return this.day();
174
+ },
175
+ dd : function (format) {
176
+ return this.lang().weekdaysMin(this, format);
177
+ },
178
+ ddd : function (format) {
179
+ return this.lang().weekdaysShort(this, format);
180
+ },
181
+ dddd : function (format) {
182
+ return this.lang().weekdays(this, format);
183
+ },
184
+ w : function () {
185
+ return this.week();
186
+ },
187
+ W : function () {
188
+ return this.isoWeek();
189
+ },
190
+ YY : function () {
191
+ return leftZeroFill(this.year() % 100, 2);
192
+ },
193
+ YYYY : function () {
194
+ return leftZeroFill(this.year(), 4);
195
+ },
196
+ YYYYY : function () {
197
+ return leftZeroFill(this.year(), 5);
198
+ },
199
+ YYYYYY : function () {
200
+ var y = this.year(), sign = y >= 0 ? '+' : '-';
201
+ return sign + leftZeroFill(Math.abs(y), 6);
202
+ },
203
+ gg : function () {
204
+ return leftZeroFill(this.weekYear() % 100, 2);
205
+ },
206
+ gggg : function () {
207
+ return leftZeroFill(this.weekYear(), 4);
208
+ },
209
+ ggggg : function () {
210
+ return leftZeroFill(this.weekYear(), 5);
211
+ },
212
+ GG : function () {
213
+ return leftZeroFill(this.isoWeekYear() % 100, 2);
214
+ },
215
+ GGGG : function () {
216
+ return leftZeroFill(this.isoWeekYear(), 4);
217
+ },
218
+ GGGGG : function () {
219
+ return leftZeroFill(this.isoWeekYear(), 5);
220
+ },
221
+ e : function () {
222
+ return this.weekday();
223
+ },
224
+ E : function () {
225
+ return this.isoWeekday();
226
+ },
227
+ a : function () {
228
+ return this.lang().meridiem(this.hours(), this.minutes(), true);
229
+ },
230
+ A : function () {
231
+ return this.lang().meridiem(this.hours(), this.minutes(), false);
232
+ },
233
+ H : function () {
234
+ return this.hours();
235
+ },
236
+ h : function () {
237
+ return this.hours() % 12 || 12;
238
+ },
239
+ m : function () {
240
+ return this.minutes();
241
+ },
242
+ s : function () {
243
+ return this.seconds();
244
+ },
245
+ S : function () {
246
+ return toInt(this.milliseconds() / 100);
247
+ },
248
+ SS : function () {
249
+ return leftZeroFill(toInt(this.milliseconds() / 10), 2);
250
+ },
251
+ SSS : function () {
252
+ return leftZeroFill(this.milliseconds(), 3);
253
+ },
254
+ SSSS : function () {
255
+ return leftZeroFill(this.milliseconds(), 3);
256
+ },
257
+ Z : function () {
258
+ var a = -this.zone(),
259
+ b = "+";
260
+ if (a < 0) {
261
+ a = -a;
262
+ b = "-";
263
+ }
264
+ return b + leftZeroFill(toInt(a / 60), 2) + ":" + leftZeroFill(toInt(a) % 60, 2);
265
+ },
266
+ ZZ : function () {
267
+ var a = -this.zone(),
268
+ b = "+";
269
+ if (a < 0) {
270
+ a = -a;
271
+ b = "-";
272
+ }
273
+ return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);
274
+ },
275
+ z : function () {
276
+ return this.zoneAbbr();
277
+ },
278
+ zz : function () {
279
+ return this.zoneName();
280
+ },
281
+ X : function () {
282
+ return this.unix();
283
+ },
284
+ Q : function () {
285
+ return this.quarter();
286
+ }
287
+ },
288
+
289
+ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
290
+
291
+ // Pick the first defined of two or three arguments. dfl comes from
292
+ // default.
293
+ function dfl(a, b, c) {
294
+ switch (arguments.length) {
295
+ case 2: return a != null ? a : b;
296
+ case 3: return a != null ? a : b != null ? b : c;
297
+ default: throw new Error("Implement me");
298
+ }
299
+ }
300
+
301
+ function defaultParsingFlags() {
302
+ // We need to deep clone this object, and es5 standard is not very
303
+ // helpful.
304
+ return {
305
+ empty : false,
306
+ unusedTokens : [],
307
+ unusedInput : [],
308
+ overflow : -2,
309
+ charsLeftOver : 0,
310
+ nullInput : false,
311
+ invalidMonth : null,
312
+ invalidFormat : false,
313
+ userInvalidated : false,
314
+ iso: false
315
+ };
316
+ }
317
+
318
+ function deprecate(msg, fn) {
319
+ var firstTime = true;
320
+ function printMsg() {
321
+ if (moment.suppressDeprecationWarnings === false &&
322
+ typeof console !== 'undefined' && console.warn) {
323
+ console.warn("Deprecation warning: " + msg);
324
+ }
325
+ }
326
+ return extend(function () {
327
+ if (firstTime) {
328
+ printMsg();
329
+ firstTime = false;
330
+ }
331
+ return fn.apply(this, arguments);
332
+ }, fn);
333
+ }
334
+
335
+ function padToken(func, count) {
336
+ return function (a) {
337
+ return leftZeroFill(func.call(this, a), count);
338
+ };
339
+ }
340
+ function ordinalizeToken(func, period) {
341
+ return function (a) {
342
+ return this.lang().ordinal(func.call(this, a), period);
343
+ };
344
+ }
345
+
346
+ while (ordinalizeTokens.length) {
347
+ i = ordinalizeTokens.pop();
348
+ formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
349
+ }
350
+ while (paddedTokens.length) {
351
+ i = paddedTokens.pop();
352
+ formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
353
+ }
354
+ formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
355
+
356
+
357
+ /************************************
358
+ Constructors
359
+ ************************************/
360
+
361
+ function Language() {
362
+
363
+ }
364
+
365
+ // Moment prototype object
366
+ function Moment(config) {
367
+ checkOverflow(config);
368
+ extend(this, config);
369
+ }
370
+
371
+ // Duration Constructor
372
+ function Duration(duration) {
373
+ var normalizedInput = normalizeObjectUnits(duration),
374
+ years = normalizedInput.year || 0,
375
+ quarters = normalizedInput.quarter || 0,
376
+ months = normalizedInput.month || 0,
377
+ weeks = normalizedInput.week || 0,
378
+ days = normalizedInput.day || 0,
379
+ hours = normalizedInput.hour || 0,
380
+ minutes = normalizedInput.minute || 0,
381
+ seconds = normalizedInput.second || 0,
382
+ milliseconds = normalizedInput.millisecond || 0;
383
+
384
+ // representation for dateAddRemove
385
+ this._milliseconds = +milliseconds +
386
+ seconds * 1e3 + // 1000
387
+ minutes * 6e4 + // 1000 * 60
388
+ hours * 36e5; // 1000 * 60 * 60
389
+ // Because of dateAddRemove treats 24 hours as different from a
390
+ // day when working around DST, we need to store them separately
391
+ this._days = +days +
392
+ weeks * 7;
393
+ // It is impossible translate months into days without knowing
394
+ // which months you are are talking about, so we have to store
395
+ // it separately.
396
+ this._months = +months +
397
+ quarters * 3 +
398
+ years * 12;
399
+
400
+ this._data = {};
401
+
402
+ this._bubble();
403
+ }
404
+
405
+ /************************************
406
+ Helpers
407
+ ************************************/
408
+
409
+
410
+ function extend(a, b) {
411
+ for (var i in b) {
412
+ if (b.hasOwnProperty(i)) {
413
+ a[i] = b[i];
414
+ }
415
+ }
416
+
417
+ if (b.hasOwnProperty("toString")) {
418
+ a.toString = b.toString;
419
+ }
420
+
421
+ if (b.hasOwnProperty("valueOf")) {
422
+ a.valueOf = b.valueOf;
423
+ }
424
+
425
+ return a;
426
+ }
427
+
428
+ function cloneMoment(m) {
429
+ var result = {}, i;
430
+ for (i in m) {
431
+ if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) {
432
+ result[i] = m[i];
433
+ }
434
+ }
435
+
436
+ return result;
437
+ }
438
+
439
+ function absRound(number) {
440
+ if (number < 0) {
441
+ return Math.ceil(number);
442
+ } else {
443
+ return Math.floor(number);
444
+ }
445
+ }
446
+
447
+ // left zero fill a number
448
+ // see http://jsperf.com/left-zero-filling for performance comparison
449
+ function leftZeroFill(number, targetLength, forceSign) {
450
+ var output = '' + Math.abs(number),
451
+ sign = number >= 0;
452
+
453
+ while (output.length < targetLength) {
454
+ output = '0' + output;
455
+ }
456
+ return (sign ? (forceSign ? '+' : '') : '-') + output;
457
+ }
458
+
459
+ // helper function for _.addTime and _.subtractTime
460
+ function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {
461
+ var milliseconds = duration._milliseconds,
462
+ days = duration._days,
463
+ months = duration._months;
464
+ updateOffset = updateOffset == null ? true : updateOffset;
465
+
466
+ if (milliseconds) {
467
+ mom._d.setTime(+mom._d + milliseconds * isAdding);
468
+ }
469
+ if (days) {
470
+ rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);
471
+ }
472
+ if (months) {
473
+ rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);
474
+ }
475
+ if (updateOffset) {
476
+ moment.updateOffset(mom, days || months);
477
+ }
478
+ }
479
+
480
+ // check if is an array
481
+ function isArray(input) {
482
+ return Object.prototype.toString.call(input) === '[object Array]';
483
+ }
484
+
485
+ function isDate(input) {
486
+ return Object.prototype.toString.call(input) === '[object Date]' ||
487
+ input instanceof Date;
488
+ }
489
+
490
+ // compare two arrays, return the number of differences
491
+ function compareArrays(array1, array2, dontConvert) {
492
+ var len = Math.min(array1.length, array2.length),
493
+ lengthDiff = Math.abs(array1.length - array2.length),
494
+ diffs = 0,
495
+ i;
496
+ for (i = 0; i < len; i++) {
497
+ if ((dontConvert && array1[i] !== array2[i]) ||
498
+ (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
499
+ diffs++;
500
+ }
501
+ }
502
+ return diffs + lengthDiff;
503
+ }
504
+
505
+ function normalizeUnits(units) {
506
+ if (units) {
507
+ var lowered = units.toLowerCase().replace(/(.)s$/, '$1');
508
+ units = unitAliases[units] || camelFunctions[lowered] || lowered;
509
+ }
510
+ return units;
511
+ }
512
+
513
+ function normalizeObjectUnits(inputObject) {
514
+ var normalizedInput = {},
515
+ normalizedProp,
516
+ prop;
517
+
518
+ for (prop in inputObject) {
519
+ if (inputObject.hasOwnProperty(prop)) {
520
+ normalizedProp = normalizeUnits(prop);
521
+ if (normalizedProp) {
522
+ normalizedInput[normalizedProp] = inputObject[prop];
523
+ }
524
+ }
525
+ }
526
+
527
+ return normalizedInput;
528
+ }
529
+
530
+ function makeList(field) {
531
+ var count, setter;
532
+
533
+ if (field.indexOf('week') === 0) {
534
+ count = 7;
535
+ setter = 'day';
536
+ }
537
+ else if (field.indexOf('month') === 0) {
538
+ count = 12;
539
+ setter = 'month';
540
+ }
541
+ else {
542
+ return;
543
+ }
544
+
545
+ moment[field] = function (format, index) {
546
+ var i, getter,
547
+ method = moment.fn._lang[field],
548
+ results = [];
549
+
550
+ if (typeof format === 'number') {
551
+ index = format;
552
+ format = undefined;
553
+ }
554
+
555
+ getter = function (i) {
556
+ var m = moment().utc().set(setter, i);
557
+ return method.call(moment.fn._lang, m, format || '');
558
+ };
559
+
560
+ if (index != null) {
561
+ return getter(index);
562
+ }
563
+ else {
564
+ for (i = 0; i < count; i++) {
565
+ results.push(getter(i));
566
+ }
567
+ return results;
568
+ }
569
+ };
570
+ }
571
+
572
+ function toInt(argumentForCoercion) {
573
+ var coercedNumber = +argumentForCoercion,
574
+ value = 0;
575
+
576
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
577
+ if (coercedNumber >= 0) {
578
+ value = Math.floor(coercedNumber);
579
+ } else {
580
+ value = Math.ceil(coercedNumber);
581
+ }
582
+ }
583
+
584
+ return value;
585
+ }
586
+
587
+ function daysInMonth(year, month) {
588
+ return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
589
+ }
590
+
591
+ function weeksInYear(year, dow, doy) {
592
+ return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;
593
+ }
594
+
595
+ function daysInYear(year) {
596
+ return isLeapYear(year) ? 366 : 365;
597
+ }
598
+
599
+ function isLeapYear(year) {
600
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
601
+ }
602
+
603
+ function checkOverflow(m) {
604
+ var overflow;
605
+ if (m._a && m._pf.overflow === -2) {
606
+ overflow =
607
+ m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
608
+ m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
609
+ m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR :
610
+ m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :
611
+ m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :
612
+ m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :
613
+ -1;
614
+
615
+ if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
616
+ overflow = DATE;
617
+ }
618
+
619
+ m._pf.overflow = overflow;
620
+ }
621
+ }
622
+
623
+ function isValid(m) {
624
+ if (m._isValid == null) {
625
+ m._isValid = !isNaN(m._d.getTime()) &&
626
+ m._pf.overflow < 0 &&
627
+ !m._pf.empty &&
628
+ !m._pf.invalidMonth &&
629
+ !m._pf.nullInput &&
630
+ !m._pf.invalidFormat &&
631
+ !m._pf.userInvalidated;
632
+
633
+ if (m._strict) {
634
+ m._isValid = m._isValid &&
635
+ m._pf.charsLeftOver === 0 &&
636
+ m._pf.unusedTokens.length === 0;
637
+ }
638
+ }
639
+ return m._isValid;
640
+ }
641
+
642
+ function normalizeLanguage(key) {
643
+ return key ? key.toLowerCase().replace('_', '-') : key;
644
+ }
645
+
646
+ // Return a moment from input, that is local/utc/zone equivalent to model.
647
+ function makeAs(input, model) {
648
+ return model._isUTC ? moment(input).zone(model._offset || 0) :
649
+ moment(input).local();
650
+ }
651
+
652
+ /************************************
653
+ Languages
654
+ ************************************/
655
+
656
+
657
+ extend(Language.prototype, {
658
+
659
+ set : function (config) {
660
+ var prop, i;
661
+ for (i in config) {
662
+ prop = config[i];
663
+ if (typeof prop === 'function') {
664
+ this[i] = prop;
665
+ } else {
666
+ this['_' + i] = prop;
667
+ }
668
+ }
669
+ },
670
+
671
+ _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
672
+ months : function (m) {
673
+ return this._months[m.month()];
674
+ },
675
+
676
+ _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
677
+ monthsShort : function (m) {
678
+ return this._monthsShort[m.month()];
679
+ },
680
+
681
+ monthsParse : function (monthName) {
682
+ var i, mom, regex;
683
+
684
+ if (!this._monthsParse) {
685
+ this._monthsParse = [];
686
+ }
687
+
688
+ for (i = 0; i < 12; i++) {
689
+ // make the regex if we don't have it already
690
+ if (!this._monthsParse[i]) {
691
+ mom = moment.utc([2000, i]);
692
+ regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
693
+ this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
694
+ }
695
+ // test the regex
696
+ if (this._monthsParse[i].test(monthName)) {
697
+ return i;
698
+ }
699
+ }
700
+ },
701
+
702
+ _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
703
+ weekdays : function (m) {
704
+ return this._weekdays[m.day()];
705
+ },
706
+
707
+ _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
708
+ weekdaysShort : function (m) {
709
+ return this._weekdaysShort[m.day()];
710
+ },
711
+
712
+ _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
713
+ weekdaysMin : function (m) {
714
+ return this._weekdaysMin[m.day()];
715
+ },
716
+
717
+ weekdaysParse : function (weekdayName) {
718
+ var i, mom, regex;
719
+
720
+ if (!this._weekdaysParse) {
721
+ this._weekdaysParse = [];
722
+ }
723
+
724
+ for (i = 0; i < 7; i++) {
725
+ // make the regex if we don't have it already
726
+ if (!this._weekdaysParse[i]) {
727
+ mom = moment([2000, 1]).day(i);
728
+ regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
729
+ this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
730
+ }
731
+ // test the regex
732
+ if (this._weekdaysParse[i].test(weekdayName)) {
733
+ return i;
734
+ }
735
+ }
736
+ },
737
+
738
+ _longDateFormat : {
739
+ LT : "h:mm A",
740
+ L : "MM/DD/YYYY",
741
+ LL : "MMMM D YYYY",
742
+ LLL : "MMMM D YYYY LT",
743
+ LLLL : "dddd, MMMM D YYYY LT"
744
+ },
745
+ longDateFormat : function (key) {
746
+ var output = this._longDateFormat[key];
747
+ if (!output && this._longDateFormat[key.toUpperCase()]) {
748
+ output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
749
+ return val.slice(1);
750
+ });
751
+ this._longDateFormat[key] = output;
752
+ }
753
+ return output;
754
+ },
755
+
756
+ isPM : function (input) {
757
+ // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
758
+ // Using charAt should be more compatible.
759
+ return ((input + '').toLowerCase().charAt(0) === 'p');
760
+ },
761
+
762
+ _meridiemParse : /[ap]\.?m?\.?/i,
763
+ meridiem : function (hours, minutes, isLower) {
764
+ if (hours > 11) {
765
+ return isLower ? 'pm' : 'PM';
766
+ } else {
767
+ return isLower ? 'am' : 'AM';
768
+ }
769
+ },
770
+
771
+ _calendar : {
772
+ sameDay : '[Today at] LT',
773
+ nextDay : '[Tomorrow at] LT',
774
+ nextWeek : 'dddd [at] LT',
775
+ lastDay : '[Yesterday at] LT',
776
+ lastWeek : '[Last] dddd [at] LT',
777
+ sameElse : 'L'
778
+ },
779
+ calendar : function (key, mom) {
780
+ var output = this._calendar[key];
781
+ return typeof output === 'function' ? output.apply(mom) : output;
782
+ },
783
+
784
+ _relativeTime : {
785
+ future : "in %s",
786
+ past : "%s ago",
787
+ s : "a few seconds",
788
+ m : "a minute",
789
+ mm : "%d minutes",
790
+ h : "an hour",
791
+ hh : "%d hours",
792
+ d : "a day",
793
+ dd : "%d days",
794
+ M : "a month",
795
+ MM : "%d months",
796
+ y : "a year",
797
+ yy : "%d years"
798
+ },
799
+ relativeTime : function (number, withoutSuffix, string, isFuture) {
800
+ var output = this._relativeTime[string];
801
+ return (typeof output === 'function') ?
802
+ output(number, withoutSuffix, string, isFuture) :
803
+ output.replace(/%d/i, number);
804
+ },
805
+ pastFuture : function (diff, output) {
806
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
807
+ return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
808
+ },
809
+
810
+ ordinal : function (number) {
811
+ return this._ordinal.replace("%d", number);
812
+ },
813
+ _ordinal : "%d",
814
+
815
+ preparse : function (string) {
816
+ return string;
817
+ },
818
+
819
+ postformat : function (string) {
820
+ return string;
821
+ },
822
+
823
+ week : function (mom) {
824
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
825
+ },
826
+
827
+ _week : {
828
+ dow : 0, // Sunday is the first day of the week.
829
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
830
+ },
831
+
832
+ _invalidDate: 'Invalid date',
833
+ invalidDate: function () {
834
+ return this._invalidDate;
835
+ }
836
+ });
837
+
838
+ // Loads a language definition into the `languages` cache. The function
839
+ // takes a key and optionally values. If not in the browser and no values
840
+ // are provided, it will load the language file module. As a convenience,
841
+ // this function also returns the language values.
842
+ function loadLang(key, values) {
843
+ values.abbr = key;
844
+ if (!languages[key]) {
845
+ languages[key] = new Language();
846
+ }
847
+ languages[key].set(values);
848
+ return languages[key];
849
+ }
850
+
851
+ // Remove a language from the `languages` cache. Mostly useful in tests.
852
+ function unloadLang(key) {
853
+ delete languages[key];
854
+ }
855
+
856
+ // Determines which language definition to use and returns it.
857
+ //
858
+ // With no parameters, it will return the global language. If you
859
+ // pass in a language key, such as 'en', it will return the
860
+ // definition for 'en', so long as 'en' has already been loaded using
861
+ // moment.lang.
862
+ function getLangDefinition(key) {
863
+ var i = 0, j, lang, next, split,
864
+ get = function (k) {
865
+ if (!languages[k] && hasModule) {
866
+ try {
867
+ require('./lang/' + k);
868
+ } catch (e) { }
869
+ }
870
+ return languages[k];
871
+ };
872
+
873
+ if (!key) {
874
+ return moment.fn._lang;
875
+ }
876
+
877
+ if (!isArray(key)) {
878
+ //short-circuit everything else
879
+ lang = get(key);
880
+ if (lang) {
881
+ return lang;
882
+ }
883
+ key = [key];
884
+ }
885
+
886
+ //pick the language from the array
887
+ //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
888
+ //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
889
+ while (i < key.length) {
890
+ split = normalizeLanguage(key[i]).split('-');
891
+ j = split.length;
892
+ next = normalizeLanguage(key[i + 1]);
893
+ next = next ? next.split('-') : null;
894
+ while (j > 0) {
895
+ lang = get(split.slice(0, j).join('-'));
896
+ if (lang) {
897
+ return lang;
898
+ }
899
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
900
+ //the next array item is better than a shallower substring of this one
901
+ break;
902
+ }
903
+ j--;
904
+ }
905
+ i++;
906
+ }
907
+ return moment.fn._lang;
908
+ }
909
+
910
+ /************************************
911
+ Formatting
912
+ ************************************/
913
+
914
+
915
+ function removeFormattingTokens(input) {
916
+ if (input.match(/\[[\s\S]/)) {
917
+ return input.replace(/^\[|\]$/g, "");
918
+ }
919
+ return input.replace(/\\/g, "");
920
+ }
921
+
922
+ function makeFormatFunction(format) {
923
+ var array = format.match(formattingTokens), i, length;
924
+
925
+ for (i = 0, length = array.length; i < length; i++) {
926
+ if (formatTokenFunctions[array[i]]) {
927
+ array[i] = formatTokenFunctions[array[i]];
928
+ } else {
929
+ array[i] = removeFormattingTokens(array[i]);
930
+ }
931
+ }
932
+
933
+ return function (mom) {
934
+ var output = "";
935
+ for (i = 0; i < length; i++) {
936
+ output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
937
+ }
938
+ return output;
939
+ };
940
+ }
941
+
942
+ // format date using native date object
943
+ function formatMoment(m, format) {
944
+
945
+ if (!m.isValid()) {
946
+ return m.lang().invalidDate();
947
+ }
948
+
949
+ format = expandFormat(format, m.lang());
950
+
951
+ if (!formatFunctions[format]) {
952
+ formatFunctions[format] = makeFormatFunction(format);
953
+ }
954
+
955
+ return formatFunctions[format](m);
956
+ }
957
+
958
+ function expandFormat(format, lang) {
959
+ var i = 5;
960
+
961
+ function replaceLongDateFormatTokens(input) {
962
+ return lang.longDateFormat(input) || input;
963
+ }
964
+
965
+ localFormattingTokens.lastIndex = 0;
966
+ while (i >= 0 && localFormattingTokens.test(format)) {
967
+ format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
968
+ localFormattingTokens.lastIndex = 0;
969
+ i -= 1;
970
+ }
971
+
972
+ return format;
973
+ }
974
+
975
+
976
+ /************************************
977
+ Parsing
978
+ ************************************/
979
+
980
+
981
+ // get the regex to find the next token
982
+ function getParseRegexForToken(token, config) {
983
+ var a, strict = config._strict;
984
+ switch (token) {
985
+ case 'Q':
986
+ return parseTokenOneDigit;
987
+ case 'DDDD':
988
+ return parseTokenThreeDigits;
989
+ case 'YYYY':
990
+ case 'GGGG':
991
+ case 'gggg':
992
+ return strict ? parseTokenFourDigits : parseTokenOneToFourDigits;
993
+ case 'Y':
994
+ case 'G':
995
+ case 'g':
996
+ return parseTokenSignedNumber;
997
+ case 'YYYYYY':
998
+ case 'YYYYY':
999
+ case 'GGGGG':
1000
+ case 'ggggg':
1001
+ return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;
1002
+ case 'S':
1003
+ if (strict) { return parseTokenOneDigit; }
1004
+ /* falls through */
1005
+ case 'SS':
1006
+ if (strict) { return parseTokenTwoDigits; }
1007
+ /* falls through */
1008
+ case 'SSS':
1009
+ if (strict) { return parseTokenThreeDigits; }
1010
+ /* falls through */
1011
+ case 'DDD':
1012
+ return parseTokenOneToThreeDigits;
1013
+ case 'MMM':
1014
+ case 'MMMM':
1015
+ case 'dd':
1016
+ case 'ddd':
1017
+ case 'dddd':
1018
+ return parseTokenWord;
1019
+ case 'a':
1020
+ case 'A':
1021
+ return getLangDefinition(config._l)._meridiemParse;
1022
+ case 'X':
1023
+ return parseTokenTimestampMs;
1024
+ case 'Z':
1025
+ case 'ZZ':
1026
+ return parseTokenTimezone;
1027
+ case 'T':
1028
+ return parseTokenT;
1029
+ case 'SSSS':
1030
+ return parseTokenDigits;
1031
+ case 'MM':
1032
+ case 'DD':
1033
+ case 'YY':
1034
+ case 'GG':
1035
+ case 'gg':
1036
+ case 'HH':
1037
+ case 'hh':
1038
+ case 'mm':
1039
+ case 'ss':
1040
+ case 'ww':
1041
+ case 'WW':
1042
+ return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits;
1043
+ case 'M':
1044
+ case 'D':
1045
+ case 'd':
1046
+ case 'H':
1047
+ case 'h':
1048
+ case 'm':
1049
+ case 's':
1050
+ case 'w':
1051
+ case 'W':
1052
+ case 'e':
1053
+ case 'E':
1054
+ return parseTokenOneOrTwoDigits;
1055
+ case 'Do':
1056
+ return parseTokenOrdinal;
1057
+ default :
1058
+ a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i"));
1059
+ return a;
1060
+ }
1061
+ }
1062
+
1063
+ function timezoneMinutesFromString(string) {
1064
+ string = string || "";
1065
+ var possibleTzMatches = (string.match(parseTokenTimezone) || []),
1066
+ tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
1067
+ parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
1068
+ minutes = +(parts[1] * 60) + toInt(parts[2]);
1069
+
1070
+ return parts[0] === '+' ? -minutes : minutes;
1071
+ }
1072
+
1073
+ // function to convert string input to date
1074
+ function addTimeToArrayFromToken(token, input, config) {
1075
+ var a, datePartArray = config._a;
1076
+
1077
+ switch (token) {
1078
+ // QUARTER
1079
+ case 'Q':
1080
+ if (input != null) {
1081
+ datePartArray[MONTH] = (toInt(input) - 1) * 3;
1082
+ }
1083
+ break;
1084
+ // MONTH
1085
+ case 'M' : // fall through to MM
1086
+ case 'MM' :
1087
+ if (input != null) {
1088
+ datePartArray[MONTH] = toInt(input) - 1;
1089
+ }
1090
+ break;
1091
+ case 'MMM' : // fall through to MMMM
1092
+ case 'MMMM' :
1093
+ a = getLangDefinition(config._l).monthsParse(input);
1094
+ // if we didn't find a month name, mark the date as invalid.
1095
+ if (a != null) {
1096
+ datePartArray[MONTH] = a;
1097
+ } else {
1098
+ config._pf.invalidMonth = input;
1099
+ }
1100
+ break;
1101
+ // DAY OF MONTH
1102
+ case 'D' : // fall through to DD
1103
+ case 'DD' :
1104
+ if (input != null) {
1105
+ datePartArray[DATE] = toInt(input);
1106
+ }
1107
+ break;
1108
+ case 'Do' :
1109
+ if (input != null) {
1110
+ datePartArray[DATE] = toInt(parseInt(input, 10));
1111
+ }
1112
+ break;
1113
+ // DAY OF YEAR
1114
+ case 'DDD' : // fall through to DDDD
1115
+ case 'DDDD' :
1116
+ if (input != null) {
1117
+ config._dayOfYear = toInt(input);
1118
+ }
1119
+
1120
+ break;
1121
+ // YEAR
1122
+ case 'YY' :
1123
+ datePartArray[YEAR] = moment.parseTwoDigitYear(input);
1124
+ break;
1125
+ case 'YYYY' :
1126
+ case 'YYYYY' :
1127
+ case 'YYYYYY' :
1128
+ datePartArray[YEAR] = toInt(input);
1129
+ break;
1130
+ // AM / PM
1131
+ case 'a' : // fall through to A
1132
+ case 'A' :
1133
+ config._isPm = getLangDefinition(config._l).isPM(input);
1134
+ break;
1135
+ // 24 HOUR
1136
+ case 'H' : // fall through to hh
1137
+ case 'HH' : // fall through to hh
1138
+ case 'h' : // fall through to hh
1139
+ case 'hh' :
1140
+ datePartArray[HOUR] = toInt(input);
1141
+ break;
1142
+ // MINUTE
1143
+ case 'm' : // fall through to mm
1144
+ case 'mm' :
1145
+ datePartArray[MINUTE] = toInt(input);
1146
+ break;
1147
+ // SECOND
1148
+ case 's' : // fall through to ss
1149
+ case 'ss' :
1150
+ datePartArray[SECOND] = toInt(input);
1151
+ break;
1152
+ // MILLISECOND
1153
+ case 'S' :
1154
+ case 'SS' :
1155
+ case 'SSS' :
1156
+ case 'SSSS' :
1157
+ datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);
1158
+ break;
1159
+ // UNIX TIMESTAMP WITH MS
1160
+ case 'X':
1161
+ config._d = new Date(parseFloat(input) * 1000);
1162
+ break;
1163
+ // TIMEZONE
1164
+ case 'Z' : // fall through to ZZ
1165
+ case 'ZZ' :
1166
+ config._useUTC = true;
1167
+ config._tzm = timezoneMinutesFromString(input);
1168
+ break;
1169
+ // WEEKDAY - human
1170
+ case 'dd':
1171
+ case 'ddd':
1172
+ case 'dddd':
1173
+ a = getLangDefinition(config._l).weekdaysParse(input);
1174
+ // if we didn't get a weekday name, mark the date as invalid
1175
+ if (a != null) {
1176
+ config._w = config._w || {};
1177
+ config._w['d'] = a;
1178
+ } else {
1179
+ config._pf.invalidWeekday = input;
1180
+ }
1181
+ break;
1182
+ // WEEK, WEEK DAY - numeric
1183
+ case 'w':
1184
+ case 'ww':
1185
+ case 'W':
1186
+ case 'WW':
1187
+ case 'd':
1188
+ case 'e':
1189
+ case 'E':
1190
+ token = token.substr(0, 1);
1191
+ /* falls through */
1192
+ case 'gggg':
1193
+ case 'GGGG':
1194
+ case 'GGGGG':
1195
+ token = token.substr(0, 2);
1196
+ if (input) {
1197
+ config._w = config._w || {};
1198
+ config._w[token] = toInt(input);
1199
+ }
1200
+ break;
1201
+ case 'gg':
1202
+ case 'GG':
1203
+ config._w = config._w || {};
1204
+ config._w[token] = moment.parseTwoDigitYear(input);
1205
+ }
1206
+ }
1207
+
1208
+ function dayOfYearFromWeekInfo(config) {
1209
+ var w, weekYear, week, weekday, dow, doy, temp, lang;
1210
+
1211
+ w = config._w;
1212
+ if (w.GG != null || w.W != null || w.E != null) {
1213
+ dow = 1;
1214
+ doy = 4;
1215
+
1216
+ // TODO: We need to take the current isoWeekYear, but that depends on
1217
+ // how we interpret now (local, utc, fixed offset). So create
1218
+ // a now version of current config (take local/utc/offset flags, and
1219
+ // create now).
1220
+ weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year);
1221
+ week = dfl(w.W, 1);
1222
+ weekday = dfl(w.E, 1);
1223
+ } else {
1224
+ lang = getLangDefinition(config._l);
1225
+ dow = lang._week.dow;
1226
+ doy = lang._week.doy;
1227
+
1228
+ weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year);
1229
+ week = dfl(w.w, 1);
1230
+
1231
+ if (w.d != null) {
1232
+ // weekday -- low day numbers are considered next week
1233
+ weekday = w.d;
1234
+ if (weekday < dow) {
1235
+ ++week;
1236
+ }
1237
+ } else if (w.e != null) {
1238
+ // local weekday -- counting starts from begining of week
1239
+ weekday = w.e + dow;
1240
+ } else {
1241
+ // default to begining of week
1242
+ weekday = dow;
1243
+ }
1244
+ }
1245
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
1246
+
1247
+ config._a[YEAR] = temp.year;
1248
+ config._dayOfYear = temp.dayOfYear;
1249
+ }
1250
+
1251
+ // convert an array to a date.
1252
+ // the array should mirror the parameters below
1253
+ // note: all values past the year are optional and will default to the lowest possible value.
1254
+ // [year, month, day , hour, minute, second, millisecond]
1255
+ function dateFromConfig(config) {
1256
+ var i, date, input = [], currentDate, yearToUse;
1257
+
1258
+ if (config._d) {
1259
+ return;
1260
+ }
1261
+
1262
+ currentDate = currentDateArray(config);
1263
+
1264
+ //compute day of the year from weeks and weekdays
1265
+ if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
1266
+ dayOfYearFromWeekInfo(config);
1267
+ }
1268
+
1269
+ //if the day of the year is set, figure out what it is
1270
+ if (config._dayOfYear) {
1271
+ yearToUse = dfl(config._a[YEAR], currentDate[YEAR]);
1272
+
1273
+ if (config._dayOfYear > daysInYear(yearToUse)) {
1274
+ config._pf._overflowDayOfYear = true;
1275
+ }
1276
+
1277
+ date = makeUTCDate(yearToUse, 0, config._dayOfYear);
1278
+ config._a[MONTH] = date.getUTCMonth();
1279
+ config._a[DATE] = date.getUTCDate();
1280
+ }
1281
+
1282
+ // Default to current date.
1283
+ // * if no year, month, day of month are given, default to today
1284
+ // * if day of month is given, default month and year
1285
+ // * if month is given, default only year
1286
+ // * if year is given, don't default anything
1287
+ for (i = 0; i < 3 && config._a[i] == null; ++i) {
1288
+ config._a[i] = input[i] = currentDate[i];
1289
+ }
1290
+
1291
+ // Zero out whatever was not defaulted, including time
1292
+ for (; i < 7; i++) {
1293
+ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
1294
+ }
1295
+
1296
+ config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
1297
+ // Apply timezone offset from input. The actual zone can be changed
1298
+ // with parseZone.
1299
+ if (config._tzm != null) {
1300
+ config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
1301
+ }
1302
+ }
1303
+
1304
+ function dateFromObject(config) {
1305
+ var normalizedInput;
1306
+
1307
+ if (config._d) {
1308
+ return;
1309
+ }
1310
+
1311
+ normalizedInput = normalizeObjectUnits(config._i);
1312
+ config._a = [
1313
+ normalizedInput.year,
1314
+ normalizedInput.month,
1315
+ normalizedInput.day,
1316
+ normalizedInput.hour,
1317
+ normalizedInput.minute,
1318
+ normalizedInput.second,
1319
+ normalizedInput.millisecond
1320
+ ];
1321
+
1322
+ dateFromConfig(config);
1323
+ }
1324
+
1325
+ function currentDateArray(config) {
1326
+ var now = new Date();
1327
+ if (config._useUTC) {
1328
+ return [
1329
+ now.getUTCFullYear(),
1330
+ now.getUTCMonth(),
1331
+ now.getUTCDate()
1332
+ ];
1333
+ } else {
1334
+ return [now.getFullYear(), now.getMonth(), now.getDate()];
1335
+ }
1336
+ }
1337
+
1338
+ // date from string and format string
1339
+ function makeDateFromStringAndFormat(config) {
1340
+
1341
+ if (config._f === moment.ISO_8601) {
1342
+ parseISO(config);
1343
+ return;
1344
+ }
1345
+
1346
+ config._a = [];
1347
+ config._pf.empty = true;
1348
+
1349
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
1350
+ var lang = getLangDefinition(config._l),
1351
+ string = '' + config._i,
1352
+ i, parsedInput, tokens, token, skipped,
1353
+ stringLength = string.length,
1354
+ totalParsedInputLength = 0;
1355
+
1356
+ tokens = expandFormat(config._f, lang).match(formattingTokens) || [];
1357
+
1358
+ for (i = 0; i < tokens.length; i++) {
1359
+ token = tokens[i];
1360
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
1361
+ if (parsedInput) {
1362
+ skipped = string.substr(0, string.indexOf(parsedInput));
1363
+ if (skipped.length > 0) {
1364
+ config._pf.unusedInput.push(skipped);
1365
+ }
1366
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
1367
+ totalParsedInputLength += parsedInput.length;
1368
+ }
1369
+ // don't parse if it's not a known token
1370
+ if (formatTokenFunctions[token]) {
1371
+ if (parsedInput) {
1372
+ config._pf.empty = false;
1373
+ }
1374
+ else {
1375
+ config._pf.unusedTokens.push(token);
1376
+ }
1377
+ addTimeToArrayFromToken(token, parsedInput, config);
1378
+ }
1379
+ else if (config._strict && !parsedInput) {
1380
+ config._pf.unusedTokens.push(token);
1381
+ }
1382
+ }
1383
+
1384
+ // add remaining unparsed input length to the string
1385
+ config._pf.charsLeftOver = stringLength - totalParsedInputLength;
1386
+ if (string.length > 0) {
1387
+ config._pf.unusedInput.push(string);
1388
+ }
1389
+
1390
+ // handle am pm
1391
+ if (config._isPm && config._a[HOUR] < 12) {
1392
+ config._a[HOUR] += 12;
1393
+ }
1394
+ // if is 12 am, change hours to 0
1395
+ if (config._isPm === false && config._a[HOUR] === 12) {
1396
+ config._a[HOUR] = 0;
1397
+ }
1398
+
1399
+ dateFromConfig(config);
1400
+ checkOverflow(config);
1401
+ }
1402
+
1403
+ function unescapeFormat(s) {
1404
+ return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
1405
+ return p1 || p2 || p3 || p4;
1406
+ });
1407
+ }
1408
+
1409
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
1410
+ function regexpEscape(s) {
1411
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
1412
+ }
1413
+
1414
+ // date from string and array of format strings
1415
+ function makeDateFromStringAndArray(config) {
1416
+ var tempConfig,
1417
+ bestMoment,
1418
+
1419
+ scoreToBeat,
1420
+ i,
1421
+ currentScore;
1422
+
1423
+ if (config._f.length === 0) {
1424
+ config._pf.invalidFormat = true;
1425
+ config._d = new Date(NaN);
1426
+ return;
1427
+ }
1428
+
1429
+ for (i = 0; i < config._f.length; i++) {
1430
+ currentScore = 0;
1431
+ tempConfig = extend({}, config);
1432
+ tempConfig._pf = defaultParsingFlags();
1433
+ tempConfig._f = config._f[i];
1434
+ makeDateFromStringAndFormat(tempConfig);
1435
+
1436
+ if (!isValid(tempConfig)) {
1437
+ continue;
1438
+ }
1439
+
1440
+ // if there is any input that was not parsed add a penalty for that format
1441
+ currentScore += tempConfig._pf.charsLeftOver;
1442
+
1443
+ //or tokens
1444
+ currentScore += tempConfig._pf.unusedTokens.length * 10;
1445
+
1446
+ tempConfig._pf.score = currentScore;
1447
+
1448
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
1449
+ scoreToBeat = currentScore;
1450
+ bestMoment = tempConfig;
1451
+ }
1452
+ }
1453
+
1454
+ extend(config, bestMoment || tempConfig);
1455
+ }
1456
+
1457
+ // date from iso format
1458
+ function parseISO(config) {
1459
+ var i, l,
1460
+ string = config._i,
1461
+ match = isoRegex.exec(string);
1462
+
1463
+ if (match) {
1464
+ config._pf.iso = true;
1465
+ for (i = 0, l = isoDates.length; i < l; i++) {
1466
+ if (isoDates[i][1].exec(string)) {
1467
+ // match[5] should be "T" or undefined
1468
+ config._f = isoDates[i][0] + (match[6] || " ");
1469
+ break;
1470
+ }
1471
+ }
1472
+ for (i = 0, l = isoTimes.length; i < l; i++) {
1473
+ if (isoTimes[i][1].exec(string)) {
1474
+ config._f += isoTimes[i][0];
1475
+ break;
1476
+ }
1477
+ }
1478
+ if (string.match(parseTokenTimezone)) {
1479
+ config._f += "Z";
1480
+ }
1481
+ makeDateFromStringAndFormat(config);
1482
+ } else {
1483
+ config._isValid = false;
1484
+ }
1485
+ }
1486
+
1487
+ // date from iso format or fallback
1488
+ function makeDateFromString(config) {
1489
+ parseISO(config);
1490
+ if (config._isValid === false) {
1491
+ delete config._isValid;
1492
+ moment.createFromInputFallback(config);
1493
+ }
1494
+ }
1495
+
1496
+ function makeDateFromInput(config) {
1497
+ var input = config._i,
1498
+ matched = aspNetJsonRegex.exec(input);
1499
+
1500
+ if (input === undefined) {
1501
+ config._d = new Date();
1502
+ } else if (matched) {
1503
+ config._d = new Date(+matched[1]);
1504
+ } else if (typeof input === 'string') {
1505
+ makeDateFromString(config);
1506
+ } else if (isArray(input)) {
1507
+ config._a = input.slice(0);
1508
+ dateFromConfig(config);
1509
+ } else if (isDate(input)) {
1510
+ config._d = new Date(+input);
1511
+ } else if (typeof(input) === 'object') {
1512
+ dateFromObject(config);
1513
+ } else if (typeof(input) === 'number') {
1514
+ // from milliseconds
1515
+ config._d = new Date(input);
1516
+ } else {
1517
+ moment.createFromInputFallback(config);
1518
+ }
1519
+ }
1520
+
1521
+ function makeDate(y, m, d, h, M, s, ms) {
1522
+ //can't just apply() to create a date:
1523
+ //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
1524
+ var date = new Date(y, m, d, h, M, s, ms);
1525
+
1526
+ //the date constructor doesn't accept years < 1970
1527
+ if (y < 1970) {
1528
+ date.setFullYear(y);
1529
+ }
1530
+ return date;
1531
+ }
1532
+
1533
+ function makeUTCDate(y) {
1534
+ var date = new Date(Date.UTC.apply(null, arguments));
1535
+ if (y < 1970) {
1536
+ date.setUTCFullYear(y);
1537
+ }
1538
+ return date;
1539
+ }
1540
+
1541
+ function parseWeekday(input, language) {
1542
+ if (typeof input === 'string') {
1543
+ if (!isNaN(input)) {
1544
+ input = parseInt(input, 10);
1545
+ }
1546
+ else {
1547
+ input = language.weekdaysParse(input);
1548
+ if (typeof input !== 'number') {
1549
+ return null;
1550
+ }
1551
+ }
1552
+ }
1553
+ return input;
1554
+ }
1555
+
1556
+ /************************************
1557
+ Relative Time
1558
+ ************************************/
1559
+
1560
+
1561
+ // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
1562
+ function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) {
1563
+ return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
1564
+ }
1565
+
1566
+ function relativeTime(milliseconds, withoutSuffix, lang) {
1567
+ var seconds = round(Math.abs(milliseconds) / 1000),
1568
+ minutes = round(seconds / 60),
1569
+ hours = round(minutes / 60),
1570
+ days = round(hours / 24),
1571
+ years = round(days / 365),
1572
+ args = seconds < relativeTimeThresholds.s && ['s', seconds] ||
1573
+ minutes === 1 && ['m'] ||
1574
+ minutes < relativeTimeThresholds.m && ['mm', minutes] ||
1575
+ hours === 1 && ['h'] ||
1576
+ hours < relativeTimeThresholds.h && ['hh', hours] ||
1577
+ days === 1 && ['d'] ||
1578
+ days <= relativeTimeThresholds.dd && ['dd', days] ||
1579
+ days <= relativeTimeThresholds.dm && ['M'] ||
1580
+ days < relativeTimeThresholds.dy && ['MM', round(days / 30)] ||
1581
+ years === 1 && ['y'] || ['yy', years];
1582
+ args[2] = withoutSuffix;
1583
+ args[3] = milliseconds > 0;
1584
+ args[4] = lang;
1585
+ return substituteTimeAgo.apply({}, args);
1586
+ }
1587
+
1588
+
1589
+ /************************************
1590
+ Week of Year
1591
+ ************************************/
1592
+
1593
+
1594
+ // firstDayOfWeek 0 = sun, 6 = sat
1595
+ // the day of the week that starts the week
1596
+ // (usually sunday or monday)
1597
+ // firstDayOfWeekOfYear 0 = sun, 6 = sat
1598
+ // the first week is the week that contains the first
1599
+ // of this day of the week
1600
+ // (eg. ISO weeks use thursday (4))
1601
+ function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
1602
+ var end = firstDayOfWeekOfYear - firstDayOfWeek,
1603
+ daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
1604
+ adjustedMoment;
1605
+
1606
+
1607
+ if (daysToDayOfWeek > end) {
1608
+ daysToDayOfWeek -= 7;
1609
+ }
1610
+
1611
+ if (daysToDayOfWeek < end - 7) {
1612
+ daysToDayOfWeek += 7;
1613
+ }
1614
+
1615
+ adjustedMoment = moment(mom).add('d', daysToDayOfWeek);
1616
+ return {
1617
+ week: Math.ceil(adjustedMoment.dayOfYear() / 7),
1618
+ year: adjustedMoment.year()
1619
+ };
1620
+ }
1621
+
1622
+ //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1623
+ function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
1624
+ var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;
1625
+
1626
+ d = d === 0 ? 7 : d;
1627
+ weekday = weekday != null ? weekday : firstDayOfWeek;
1628
+ daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
1629
+ dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
1630
+
1631
+ return {
1632
+ year: dayOfYear > 0 ? year : year - 1,
1633
+ dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
1634
+ };
1635
+ }
1636
+
1637
+ /************************************
1638
+ Top Level Functions
1639
+ ************************************/
1640
+
1641
+ function makeMoment(config) {
1642
+ var input = config._i,
1643
+ format = config._f;
1644
+
1645
+ if (input === null || (format === undefined && input === '')) {
1646
+ return moment.invalid({nullInput: true});
1647
+ }
1648
+
1649
+ if (typeof input === 'string') {
1650
+ config._i = input = getLangDefinition().preparse(input);
1651
+ }
1652
+
1653
+ if (moment.isMoment(input)) {
1654
+ config = cloneMoment(input);
1655
+
1656
+ config._d = new Date(+input._d);
1657
+ } else if (format) {
1658
+ if (isArray(format)) {
1659
+ makeDateFromStringAndArray(config);
1660
+ } else {
1661
+ makeDateFromStringAndFormat(config);
1662
+ }
1663
+ } else {
1664
+ makeDateFromInput(config);
1665
+ }
1666
+
1667
+ return new Moment(config);
1668
+ }
1669
+
1670
+ moment = function (input, format, lang, strict) {
1671
+ var c;
1672
+
1673
+ if (typeof(lang) === "boolean") {
1674
+ strict = lang;
1675
+ lang = undefined;
1676
+ }
1677
+ // object construction must be done this way.
1678
+ // https://github.com/moment/moment/issues/1423
1679
+ c = {};
1680
+ c._isAMomentObject = true;
1681
+ c._i = input;
1682
+ c._f = format;
1683
+ c._l = lang;
1684
+ c._strict = strict;
1685
+ c._isUTC = false;
1686
+ c._pf = defaultParsingFlags();
1687
+
1688
+ return makeMoment(c);
1689
+ };
1690
+
1691
+ moment.suppressDeprecationWarnings = false;
1692
+
1693
+ moment.createFromInputFallback = deprecate(
1694
+ "moment construction falls back to js Date. This is " +
1695
+ "discouraged and will be removed in upcoming major " +
1696
+ "release. Please refer to " +
1697
+ "https://github.com/moment/moment/issues/1407 for more info.",
1698
+ function (config) {
1699
+ config._d = new Date(config._i);
1700
+ });
1701
+
1702
+ // Pick a moment m from moments so that m[fn](other) is true for all
1703
+ // other. This relies on the function fn to be transitive.
1704
+ //
1705
+ // moments should either be an array of moment objects or an array, whose
1706
+ // first element is an array of moment objects.
1707
+ function pickBy(fn, moments) {
1708
+ var res, i;
1709
+ if (moments.length === 1 && isArray(moments[0])) {
1710
+ moments = moments[0];
1711
+ }
1712
+ if (!moments.length) {
1713
+ return moment();
1714
+ }
1715
+ res = moments[0];
1716
+ for (i = 1; i < moments.length; ++i) {
1717
+ if (moments[i][fn](res)) {
1718
+ res = moments[i];
1719
+ }
1720
+ }
1721
+ return res;
1722
+ }
1723
+
1724
+ moment.min = function () {
1725
+ var args = [].slice.call(arguments, 0);
1726
+
1727
+ return pickBy('isBefore', args);
1728
+ };
1729
+
1730
+ moment.max = function () {
1731
+ var args = [].slice.call(arguments, 0);
1732
+
1733
+ return pickBy('isAfter', args);
1734
+ };
1735
+
1736
+ // creating with utc
1737
+ moment.utc = function (input, format, lang, strict) {
1738
+ var c;
1739
+
1740
+ if (typeof(lang) === "boolean") {
1741
+ strict = lang;
1742
+ lang = undefined;
1743
+ }
1744
+ // object construction must be done this way.
1745
+ // https://github.com/moment/moment/issues/1423
1746
+ c = {};
1747
+ c._isAMomentObject = true;
1748
+ c._useUTC = true;
1749
+ c._isUTC = true;
1750
+ c._l = lang;
1751
+ c._i = input;
1752
+ c._f = format;
1753
+ c._strict = strict;
1754
+ c._pf = defaultParsingFlags();
1755
+
1756
+ return makeMoment(c).utc();
1757
+ };
1758
+
1759
+ // creating with unix timestamp (in seconds)
1760
+ moment.unix = function (input) {
1761
+ return moment(input * 1000);
1762
+ };
1763
+
1764
+ // duration
1765
+ moment.duration = function (input, key) {
1766
+ var duration = input,
1767
+ // matching against regexp is expensive, do it on demand
1768
+ match = null,
1769
+ sign,
1770
+ ret,
1771
+ parseIso;
1772
+
1773
+ if (moment.isDuration(input)) {
1774
+ duration = {
1775
+ ms: input._milliseconds,
1776
+ d: input._days,
1777
+ M: input._months
1778
+ };
1779
+ } else if (typeof input === 'number') {
1780
+ duration = {};
1781
+ if (key) {
1782
+ duration[key] = input;
1783
+ } else {
1784
+ duration.milliseconds = input;
1785
+ }
1786
+ } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {
1787
+ sign = (match[1] === "-") ? -1 : 1;
1788
+ duration = {
1789
+ y: 0,
1790
+ d: toInt(match[DATE]) * sign,
1791
+ h: toInt(match[HOUR]) * sign,
1792
+ m: toInt(match[MINUTE]) * sign,
1793
+ s: toInt(match[SECOND]) * sign,
1794
+ ms: toInt(match[MILLISECOND]) * sign
1795
+ };
1796
+ } else if (!!(match = isoDurationRegex.exec(input))) {
1797
+ sign = (match[1] === "-") ? -1 : 1;
1798
+ parseIso = function (inp) {
1799
+ // We'd normally use ~~inp for this, but unfortunately it also
1800
+ // converts floats to ints.
1801
+ // inp may be undefined, so careful calling replace on it.
1802
+ var res = inp && parseFloat(inp.replace(',', '.'));
1803
+ // apply sign while we're at it
1804
+ return (isNaN(res) ? 0 : res) * sign;
1805
+ };
1806
+ duration = {
1807
+ y: parseIso(match[2]),
1808
+ M: parseIso(match[3]),
1809
+ d: parseIso(match[4]),
1810
+ h: parseIso(match[5]),
1811
+ m: parseIso(match[6]),
1812
+ s: parseIso(match[7]),
1813
+ w: parseIso(match[8])
1814
+ };
1815
+ }
1816
+
1817
+ ret = new Duration(duration);
1818
+
1819
+ if (moment.isDuration(input) && input.hasOwnProperty('_lang')) {
1820
+ ret._lang = input._lang;
1821
+ }
1822
+
1823
+ return ret;
1824
+ };
1825
+
1826
+ // version number
1827
+ moment.version = VERSION;
1828
+
1829
+ // default format
1830
+ moment.defaultFormat = isoFormat;
1831
+
1832
+ // constant that refers to the ISO standard
1833
+ moment.ISO_8601 = function () {};
1834
+
1835
+ // Plugins that add properties should also add the key here (null value),
1836
+ // so we can properly clone ourselves.
1837
+ moment.momentProperties = momentProperties;
1838
+
1839
+ // This function will be called whenever a moment is mutated.
1840
+ // It is intended to keep the offset in sync with the timezone.
1841
+ moment.updateOffset = function () {};
1842
+
1843
+ // This function allows you to set a threshold for relative time strings
1844
+ moment.relativeTimeThreshold = function(threshold, limit) {
1845
+ if (relativeTimeThresholds[threshold] === undefined) {
1846
+ return false;
1847
+ }
1848
+ relativeTimeThresholds[threshold] = limit;
1849
+ return true;
1850
+ };
1851
+
1852
+ // This function will load languages and then set the global language. If
1853
+ // no arguments are passed in, it will simply return the current global
1854
+ // language key.
1855
+ moment.lang = function (key, values) {
1856
+ var r;
1857
+ if (!key) {
1858
+ return moment.fn._lang._abbr;
1859
+ }
1860
+ if (values) {
1861
+ loadLang(normalizeLanguage(key), values);
1862
+ } else if (values === null) {
1863
+ unloadLang(key);
1864
+ key = 'en';
1865
+ } else if (!languages[key]) {
1866
+ getLangDefinition(key);
1867
+ }
1868
+ r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
1869
+ return r._abbr;
1870
+ };
1871
+
1872
+ // returns language data
1873
+ moment.langData = function (key) {
1874
+ if (key && key._lang && key._lang._abbr) {
1875
+ key = key._lang._abbr;
1876
+ }
1877
+ return getLangDefinition(key);
1878
+ };
1879
+
1880
+ // compare moment object
1881
+ moment.isMoment = function (obj) {
1882
+ return obj instanceof Moment ||
1883
+ (obj != null && obj.hasOwnProperty('_isAMomentObject'));
1884
+ };
1885
+
1886
+ // for typechecking Duration objects
1887
+ moment.isDuration = function (obj) {
1888
+ return obj instanceof Duration;
1889
+ };
1890
+
1891
+ for (i = lists.length - 1; i >= 0; --i) {
1892
+ makeList(lists[i]);
1893
+ }
1894
+
1895
+ moment.normalizeUnits = function (units) {
1896
+ return normalizeUnits(units);
1897
+ };
1898
+
1899
+ moment.invalid = function (flags) {
1900
+ var m = moment.utc(NaN);
1901
+ if (flags != null) {
1902
+ extend(m._pf, flags);
1903
+ }
1904
+ else {
1905
+ m._pf.userInvalidated = true;
1906
+ }
1907
+
1908
+ return m;
1909
+ };
1910
+
1911
+ moment.parseZone = function () {
1912
+ return moment.apply(null, arguments).parseZone();
1913
+ };
1914
+
1915
+ moment.parseTwoDigitYear = function (input) {
1916
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
1917
+ };
1918
+
1919
+ /************************************
1920
+ Moment Prototype
1921
+ ************************************/
1922
+
1923
+
1924
+ extend(moment.fn = Moment.prototype, {
1925
+
1926
+ clone : function () {
1927
+ return moment(this);
1928
+ },
1929
+
1930
+ valueOf : function () {
1931
+ return +this._d + ((this._offset || 0) * 60000);
1932
+ },
1933
+
1934
+ unix : function () {
1935
+ return Math.floor(+this / 1000);
1936
+ },
1937
+
1938
+ toString : function () {
1939
+ return this.clone().lang('en').format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
1940
+ },
1941
+
1942
+ toDate : function () {
1943
+ return this._offset ? new Date(+this) : this._d;
1944
+ },
1945
+
1946
+ toISOString : function () {
1947
+ var m = moment(this).utc();
1948
+ if (0 < m.year() && m.year() <= 9999) {
1949
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1950
+ } else {
1951
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1952
+ }
1953
+ },
1954
+
1955
+ toArray : function () {
1956
+ var m = this;
1957
+ return [
1958
+ m.year(),
1959
+ m.month(),
1960
+ m.date(),
1961
+ m.hours(),
1962
+ m.minutes(),
1963
+ m.seconds(),
1964
+ m.milliseconds()
1965
+ ];
1966
+ },
1967
+
1968
+ isValid : function () {
1969
+ return isValid(this);
1970
+ },
1971
+
1972
+ isDSTShifted : function () {
1973
+
1974
+ if (this._a) {
1975
+ return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0;
1976
+ }
1977
+
1978
+ return false;
1979
+ },
1980
+
1981
+ parsingFlags : function () {
1982
+ return extend({}, this._pf);
1983
+ },
1984
+
1985
+ invalidAt: function () {
1986
+ return this._pf.overflow;
1987
+ },
1988
+
1989
+ utc : function () {
1990
+ return this.zone(0);
1991
+ },
1992
+
1993
+ local : function () {
1994
+ this.zone(0);
1995
+ this._isUTC = false;
1996
+ return this;
1997
+ },
1998
+
1999
+ format : function (inputString) {
2000
+ var output = formatMoment(this, inputString || moment.defaultFormat);
2001
+ return this.lang().postformat(output);
2002
+ },
2003
+
2004
+ add : function (input, val) {
2005
+ var dur;
2006
+ // switch args to support add('s', 1) and add(1, 's')
2007
+ if (typeof input === 'string' && typeof val === 'string') {
2008
+ dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input);
2009
+ } else if (typeof input === 'string') {
2010
+ dur = moment.duration(+val, input);
2011
+ } else {
2012
+ dur = moment.duration(input, val);
2013
+ }
2014
+ addOrSubtractDurationFromMoment(this, dur, 1);
2015
+ return this;
2016
+ },
2017
+
2018
+ subtract : function (input, val) {
2019
+ var dur;
2020
+ // switch args to support subtract('s', 1) and subtract(1, 's')
2021
+ if (typeof input === 'string' && typeof val === 'string') {
2022
+ dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input);
2023
+ } else if (typeof input === 'string') {
2024
+ dur = moment.duration(+val, input);
2025
+ } else {
2026
+ dur = moment.duration(input, val);
2027
+ }
2028
+ addOrSubtractDurationFromMoment(this, dur, -1);
2029
+ return this;
2030
+ },
2031
+
2032
+ diff : function (input, units, asFloat) {
2033
+ var that = makeAs(input, this),
2034
+ zoneDiff = (this.zone() - that.zone()) * 6e4,
2035
+ diff, output;
2036
+
2037
+ units = normalizeUnits(units);
2038
+
2039
+ if (units === 'year' || units === 'month') {
2040
+ // average number of days in the months in the given dates
2041
+ diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
2042
+ // difference in months
2043
+ output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
2044
+ // adjust by taking difference in days, average number of days
2045
+ // and dst in the given months.
2046
+ output += ((this - moment(this).startOf('month')) -
2047
+ (that - moment(that).startOf('month'))) / diff;
2048
+ // same as above but with zones, to negate all dst
2049
+ output -= ((this.zone() - moment(this).startOf('month').zone()) -
2050
+ (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
2051
+ if (units === 'year') {
2052
+ output = output / 12;
2053
+ }
2054
+ } else {
2055
+ diff = (this - that);
2056
+ output = units === 'second' ? diff / 1e3 : // 1000
2057
+ units === 'minute' ? diff / 6e4 : // 1000 * 60
2058
+ units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
2059
+ units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
2060
+ units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
2061
+ diff;
2062
+ }
2063
+ return asFloat ? output : absRound(output);
2064
+ },
2065
+
2066
+ from : function (time, withoutSuffix) {
2067
+ return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix);
2068
+ },
2069
+
2070
+ fromNow : function (withoutSuffix) {
2071
+ return this.from(moment(), withoutSuffix);
2072
+ },
2073
+
2074
+ calendar : function (time) {
2075
+ // We want to compare the start of today, vs this.
2076
+ // Getting start-of-today depends on whether we're zone'd or not.
2077
+ var now = time || moment(),
2078
+ sod = makeAs(now, this).startOf('day'),
2079
+ diff = this.diff(sod, 'days', true),
2080
+ format = diff < -6 ? 'sameElse' :
2081
+ diff < -1 ? 'lastWeek' :
2082
+ diff < 0 ? 'lastDay' :
2083
+ diff < 1 ? 'sameDay' :
2084
+ diff < 2 ? 'nextDay' :
2085
+ diff < 7 ? 'nextWeek' : 'sameElse';
2086
+ return this.format(this.lang().calendar(format, this));
2087
+ },
2088
+
2089
+ isLeapYear : function () {
2090
+ return isLeapYear(this.year());
2091
+ },
2092
+
2093
+ isDST : function () {
2094
+ return (this.zone() < this.clone().month(0).zone() ||
2095
+ this.zone() < this.clone().month(5).zone());
2096
+ },
2097
+
2098
+ day : function (input) {
2099
+ var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
2100
+ if (input != null) {
2101
+ input = parseWeekday(input, this.lang());
2102
+ return this.add({ d : input - day });
2103
+ } else {
2104
+ return day;
2105
+ }
2106
+ },
2107
+
2108
+ month : makeAccessor('Month', true),
2109
+
2110
+ startOf: function (units) {
2111
+ units = normalizeUnits(units);
2112
+ // the following switch intentionally omits break keywords
2113
+ // to utilize falling through the cases.
2114
+ switch (units) {
2115
+ case 'year':
2116
+ this.month(0);
2117
+ /* falls through */
2118
+ case 'quarter':
2119
+ case 'month':
2120
+ this.date(1);
2121
+ /* falls through */
2122
+ case 'week':
2123
+ case 'isoWeek':
2124
+ case 'day':
2125
+ this.hours(0);
2126
+ /* falls through */
2127
+ case 'hour':
2128
+ this.minutes(0);
2129
+ /* falls through */
2130
+ case 'minute':
2131
+ this.seconds(0);
2132
+ /* falls through */
2133
+ case 'second':
2134
+ this.milliseconds(0);
2135
+ /* falls through */
2136
+ }
2137
+
2138
+ // weeks are a special case
2139
+ if (units === 'week') {
2140
+ this.weekday(0);
2141
+ } else if (units === 'isoWeek') {
2142
+ this.isoWeekday(1);
2143
+ }
2144
+
2145
+ // quarters are also special
2146
+ if (units === 'quarter') {
2147
+ this.month(Math.floor(this.month() / 3) * 3);
2148
+ }
2149
+
2150
+ return this;
2151
+ },
2152
+
2153
+ endOf: function (units) {
2154
+ units = normalizeUnits(units);
2155
+ return this.startOf(units).add((units === 'isoWeek' ? 'week' : units), 1).subtract('ms', 1);
2156
+ },
2157
+
2158
+ isAfter: function (input, units) {
2159
+ units = typeof units !== 'undefined' ? units : 'millisecond';
2160
+ return +this.clone().startOf(units) > +moment(input).startOf(units);
2161
+ },
2162
+
2163
+ isBefore: function (input, units) {
2164
+ units = typeof units !== 'undefined' ? units : 'millisecond';
2165
+ return +this.clone().startOf(units) < +moment(input).startOf(units);
2166
+ },
2167
+
2168
+ isSame: function (input, units) {
2169
+ units = units || 'ms';
2170
+ return +this.clone().startOf(units) === +makeAs(input, this).startOf(units);
2171
+ },
2172
+
2173
+ min: deprecate(
2174
+ "moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",
2175
+ function (other) {
2176
+ other = moment.apply(null, arguments);
2177
+ return other < this ? this : other;
2178
+ }
2179
+ ),
2180
+
2181
+ max: deprecate(
2182
+ "moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",
2183
+ function (other) {
2184
+ other = moment.apply(null, arguments);
2185
+ return other > this ? this : other;
2186
+ }
2187
+ ),
2188
+
2189
+ // keepTime = true means only change the timezone, without affecting
2190
+ // the local hour. So 5:31:26 +0300 --[zone(2, true)]--> 5:31:26 +0200
2191
+ // It is possible that 5:31:26 doesn't exist int zone +0200, so we
2192
+ // adjust the time as needed, to be valid.
2193
+ //
2194
+ // Keeping the time actually adds/subtracts (one hour)
2195
+ // from the actual represented time. That is why we call updateOffset
2196
+ // a second time. In case it wants us to change the offset again
2197
+ // _changeInProgress == true case, then we have to adjust, because
2198
+ // there is no such time in the given timezone.
2199
+ zone : function (input, keepTime) {
2200
+ var offset = this._offset || 0;
2201
+ if (input != null) {
2202
+ if (typeof input === "string") {
2203
+ input = timezoneMinutesFromString(input);
2204
+ }
2205
+ if (Math.abs(input) < 16) {
2206
+ input = input * 60;
2207
+ }
2208
+ this._offset = input;
2209
+ this._isUTC = true;
2210
+ if (offset !== input) {
2211
+ if (!keepTime || this._changeInProgress) {
2212
+ addOrSubtractDurationFromMoment(this,
2213
+ moment.duration(offset - input, 'm'), 1, false);
2214
+ } else if (!this._changeInProgress) {
2215
+ this._changeInProgress = true;
2216
+ moment.updateOffset(this, true);
2217
+ this._changeInProgress = null;
2218
+ }
2219
+ }
2220
+ } else {
2221
+ return this._isUTC ? offset : this._d.getTimezoneOffset();
2222
+ }
2223
+ return this;
2224
+ },
2225
+
2226
+ zoneAbbr : function () {
2227
+ return this._isUTC ? "UTC" : "";
2228
+ },
2229
+
2230
+ zoneName : function () {
2231
+ return this._isUTC ? "Coordinated Universal Time" : "";
2232
+ },
2233
+
2234
+ parseZone : function () {
2235
+ if (this._tzm) {
2236
+ this.zone(this._tzm);
2237
+ } else if (typeof this._i === 'string') {
2238
+ this.zone(this._i);
2239
+ }
2240
+ return this;
2241
+ },
2242
+
2243
+ hasAlignedHourOffset : function (input) {
2244
+ if (!input) {
2245
+ input = 0;
2246
+ }
2247
+ else {
2248
+ input = moment(input).zone();
2249
+ }
2250
+
2251
+ return (this.zone() - input) % 60 === 0;
2252
+ },
2253
+
2254
+ daysInMonth : function () {
2255
+ return daysInMonth(this.year(), this.month());
2256
+ },
2257
+
2258
+ dayOfYear : function (input) {
2259
+ var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
2260
+ return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
2261
+ },
2262
+
2263
+ quarter : function (input) {
2264
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
2265
+ },
2266
+
2267
+ weekYear : function (input) {
2268
+ var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year;
2269
+ return input == null ? year : this.add("y", (input - year));
2270
+ },
2271
+
2272
+ isoWeekYear : function (input) {
2273
+ var year = weekOfYear(this, 1, 4).year;
2274
+ return input == null ? year : this.add("y", (input - year));
2275
+ },
2276
+
2277
+ week : function (input) {
2278
+ var week = this.lang().week(this);
2279
+ return input == null ? week : this.add("d", (input - week) * 7);
2280
+ },
2281
+
2282
+ isoWeek : function (input) {
2283
+ var week = weekOfYear(this, 1, 4).week;
2284
+ return input == null ? week : this.add("d", (input - week) * 7);
2285
+ },
2286
+
2287
+ weekday : function (input) {
2288
+ var weekday = (this.day() + 7 - this.lang()._week.dow) % 7;
2289
+ return input == null ? weekday : this.add("d", input - weekday);
2290
+ },
2291
+
2292
+ isoWeekday : function (input) {
2293
+ // behaves the same as moment#day except
2294
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
2295
+ // as a setter, sunday should belong to the previous week.
2296
+ return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
2297
+ },
2298
+
2299
+ isoWeeksInYear : function () {
2300
+ return weeksInYear(this.year(), 1, 4);
2301
+ },
2302
+
2303
+ weeksInYear : function () {
2304
+ var weekInfo = this._lang._week;
2305
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
2306
+ },
2307
+
2308
+ get : function (units) {
2309
+ units = normalizeUnits(units);
2310
+ return this[units]();
2311
+ },
2312
+
2313
+ set : function (units, value) {
2314
+ units = normalizeUnits(units);
2315
+ if (typeof this[units] === 'function') {
2316
+ this[units](value);
2317
+ }
2318
+ return this;
2319
+ },
2320
+
2321
+ // If passed a language key, it will set the language for this
2322
+ // instance. Otherwise, it will return the language configuration
2323
+ // variables for this instance.
2324
+ lang : function (key) {
2325
+ if (key === undefined) {
2326
+ return this._lang;
2327
+ } else {
2328
+ this._lang = getLangDefinition(key);
2329
+ return this;
2330
+ }
2331
+ }
2332
+ });
2333
+
2334
+ function rawMonthSetter(mom, value) {
2335
+ var dayOfMonth;
2336
+
2337
+ // TODO: Move this out of here!
2338
+ if (typeof value === 'string') {
2339
+ value = mom.lang().monthsParse(value);
2340
+ // TODO: Another silent failure?
2341
+ if (typeof value !== 'number') {
2342
+ return mom;
2343
+ }
2344
+ }
2345
+
2346
+ dayOfMonth = Math.min(mom.date(),
2347
+ daysInMonth(mom.year(), value));
2348
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
2349
+ return mom;
2350
+ }
2351
+
2352
+ function rawGetter(mom, unit) {
2353
+ return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
2354
+ }
2355
+
2356
+ function rawSetter(mom, unit, value) {
2357
+ if (unit === 'Month') {
2358
+ return rawMonthSetter(mom, value);
2359
+ } else {
2360
+ return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
2361
+ }
2362
+ }
2363
+
2364
+ function makeAccessor(unit, keepTime) {
2365
+ return function (value) {
2366
+ if (value != null) {
2367
+ rawSetter(this, unit, value);
2368
+ moment.updateOffset(this, keepTime);
2369
+ return this;
2370
+ } else {
2371
+ return rawGetter(this, unit);
2372
+ }
2373
+ };
2374
+ }
2375
+
2376
+ moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);
2377
+ moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);
2378
+ moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);
2379
+ // Setting the hour should keep the time, because the user explicitly
2380
+ // specified which hour he wants. So trying to maintain the same hour (in
2381
+ // a new timezone) makes sense. Adding/subtracting hours does not follow
2382
+ // this rule.
2383
+ moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);
2384
+ // moment.fn.month is defined separately
2385
+ moment.fn.date = makeAccessor('Date', true);
2386
+ moment.fn.dates = deprecate("dates accessor is deprecated. Use date instead.", makeAccessor('Date', true));
2387
+ moment.fn.year = makeAccessor('FullYear', true);
2388
+ moment.fn.years = deprecate("years accessor is deprecated. Use year instead.", makeAccessor('FullYear', true));
2389
+
2390
+ // add plural methods
2391
+ moment.fn.days = moment.fn.day;
2392
+ moment.fn.months = moment.fn.month;
2393
+ moment.fn.weeks = moment.fn.week;
2394
+ moment.fn.isoWeeks = moment.fn.isoWeek;
2395
+ moment.fn.quarters = moment.fn.quarter;
2396
+
2397
+ // add aliased format methods
2398
+ moment.fn.toJSON = moment.fn.toISOString;
2399
+
2400
+ /************************************
2401
+ Duration Prototype
2402
+ ************************************/
2403
+
2404
+
2405
+ extend(moment.duration.fn = Duration.prototype, {
2406
+
2407
+ _bubble : function () {
2408
+ var milliseconds = this._milliseconds,
2409
+ days = this._days,
2410
+ months = this._months,
2411
+ data = this._data,
2412
+ seconds, minutes, hours, years;
2413
+
2414
+ // The following code bubbles up values, see the tests for
2415
+ // examples of what that means.
2416
+ data.milliseconds = milliseconds % 1000;
2417
+
2418
+ seconds = absRound(milliseconds / 1000);
2419
+ data.seconds = seconds % 60;
2420
+
2421
+ minutes = absRound(seconds / 60);
2422
+ data.minutes = minutes % 60;
2423
+
2424
+ hours = absRound(minutes / 60);
2425
+ data.hours = hours % 24;
2426
+
2427
+ days += absRound(hours / 24);
2428
+ data.days = days % 30;
2429
+
2430
+ months += absRound(days / 30);
2431
+ data.months = months % 12;
2432
+
2433
+ years = absRound(months / 12);
2434
+ data.years = years;
2435
+ },
2436
+
2437
+ weeks : function () {
2438
+ return absRound(this.days() / 7);
2439
+ },
2440
+
2441
+ valueOf : function () {
2442
+ return this._milliseconds +
2443
+ this._days * 864e5 +
2444
+ (this._months % 12) * 2592e6 +
2445
+ toInt(this._months / 12) * 31536e6;
2446
+ },
2447
+
2448
+ humanize : function (withSuffix) {
2449
+ var difference = +this,
2450
+ output = relativeTime(difference, !withSuffix, this.lang());
2451
+
2452
+ if (withSuffix) {
2453
+ output = this.lang().pastFuture(difference, output);
2454
+ }
2455
+
2456
+ return this.lang().postformat(output);
2457
+ },
2458
+
2459
+ add : function (input, val) {
2460
+ // supports only 2.0-style add(1, 's') or add(moment)
2461
+ var dur = moment.duration(input, val);
2462
+
2463
+ this._milliseconds += dur._milliseconds;
2464
+ this._days += dur._days;
2465
+ this._months += dur._months;
2466
+
2467
+ this._bubble();
2468
+
2469
+ return this;
2470
+ },
2471
+
2472
+ subtract : function (input, val) {
2473
+ var dur = moment.duration(input, val);
2474
+
2475
+ this._milliseconds -= dur._milliseconds;
2476
+ this._days -= dur._days;
2477
+ this._months -= dur._months;
2478
+
2479
+ this._bubble();
2480
+
2481
+ return this;
2482
+ },
2483
+
2484
+ get : function (units) {
2485
+ units = normalizeUnits(units);
2486
+ return this[units.toLowerCase() + 's']();
2487
+ },
2488
+
2489
+ as : function (units) {
2490
+ units = normalizeUnits(units);
2491
+ return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's']();
2492
+ },
2493
+
2494
+ lang : moment.fn.lang,
2495
+
2496
+ toIsoString : function () {
2497
+ // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
2498
+ var years = Math.abs(this.years()),
2499
+ months = Math.abs(this.months()),
2500
+ days = Math.abs(this.days()),
2501
+ hours = Math.abs(this.hours()),
2502
+ minutes = Math.abs(this.minutes()),
2503
+ seconds = Math.abs(this.seconds() + this.milliseconds() / 1000);
2504
+
2505
+ if (!this.asSeconds()) {
2506
+ // this is the same as C#'s (Noda) and python (isodate)...
2507
+ // but not other JS (goog.date)
2508
+ return 'P0D';
2509
+ }
2510
+
2511
+ return (this.asSeconds() < 0 ? '-' : '') +
2512
+ 'P' +
2513
+ (years ? years + 'Y' : '') +
2514
+ (months ? months + 'M' : '') +
2515
+ (days ? days + 'D' : '') +
2516
+ ((hours || minutes || seconds) ? 'T' : '') +
2517
+ (hours ? hours + 'H' : '') +
2518
+ (minutes ? minutes + 'M' : '') +
2519
+ (seconds ? seconds + 'S' : '');
2520
+ }
2521
+ });
2522
+
2523
+ function makeDurationGetter(name) {
2524
+ moment.duration.fn[name] = function () {
2525
+ return this._data[name];
2526
+ };
2527
+ }
2528
+
2529
+ function makeDurationAsGetter(name, factor) {
2530
+ moment.duration.fn['as' + name] = function () {
2531
+ return +this / factor;
2532
+ };
2533
+ }
2534
+
2535
+ for (i in unitMillisecondFactors) {
2536
+ if (unitMillisecondFactors.hasOwnProperty(i)) {
2537
+ makeDurationAsGetter(i, unitMillisecondFactors[i]);
2538
+ makeDurationGetter(i.toLowerCase());
2539
+ }
2540
+ }
2541
+
2542
+ makeDurationAsGetter('Weeks', 6048e5);
2543
+ moment.duration.fn.asMonths = function () {
2544
+ return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12;
2545
+ };
2546
+
2547
+
2548
+ /************************************
2549
+ Default Lang
2550
+ ************************************/
2551
+
2552
+
2553
+ // Set default language, other languages will inherit from English.
2554
+ moment.lang('en', {
2555
+ ordinal : function (number) {
2556
+ var b = number % 10,
2557
+ output = (toInt(number % 100 / 10) === 1) ? 'th' :
2558
+ (b === 1) ? 'st' :
2559
+ (b === 2) ? 'nd' :
2560
+ (b === 3) ? 'rd' : 'th';
2561
+ return number + output;
2562
+ }
2563
+ });
2564
+
2565
+ /* EMBED_LANGUAGES */
2566
+
2567
+ /************************************
2568
+ Exposing Moment
2569
+ ************************************/
2570
+
2571
+ function makeGlobal(shouldDeprecate) {
2572
+ /*global ender:false */
2573
+ if (typeof ender !== 'undefined') {
2574
+ return;
2575
+ }
2576
+ oldGlobalMoment = globalScope.moment;
2577
+ if (shouldDeprecate) {
2578
+ globalScope.moment = deprecate(
2579
+ "Accessing Moment through the global scope is " +
2580
+ "deprecated, and will be removed in an upcoming " +
2581
+ "release.",
2582
+ moment);
2583
+ } else {
2584
+ globalScope.moment = moment;
2585
+ }
2586
+ }
2587
+
2588
+ // CommonJS module is defined
2589
+ if (hasModule) {
2590
+ module.exports = moment;
2591
+ } else if (typeof define === "function" && define.amd) {
2592
+ define("moment", function (require, exports, module) {
2593
+ if (module.config && module.config() && module.config().noGlobal === true) {
2594
+ // release the global variable
2595
+ globalScope.moment = oldGlobalMoment;
2596
+ }
2597
+
2598
+ return moment;
2599
+ });
2600
+ makeGlobal(true);
2601
+ } else {
2602
+ makeGlobal();
2603
+ }
2604
+ }).call(this);