3 ;(
function (global, factory) {
4 typeof exports ===
'object' && typeof module !==
'undefined' ? module.exports = factory() :
5 typeof define ===
'function' && define.amd ? define(factory) :
6 global.moment = factory()
7 }(this, (function () {
'use strict';
12 return hookCallback.apply(null, arguments);
17 function setHookCallback (callback) {
18 hookCallback = callback;
21 function isArray(input) {
22 return input instanceof Array || Object.prototype.toString.call(input) ===
'[object Array]';
25 function isObject(input) {
28 return input != null && Object.prototype.toString.call(input) ===
'[object Object]';
31 function isObjectEmpty(obj) {
32 if (Object.getOwnPropertyNames) {
33 return (Object.getOwnPropertyNames(obj).length === 0);
37 if (obj.hasOwnProperty(k)) {
45 function isUndefined(input) {
46 return input ===
void 0;
49 function isNumber(input) {
50 return typeof input ===
'number' || Object.prototype.toString.call(input) ===
'[object Number]';
53 function isDate(input) {
54 return input instanceof Date || Object.prototype.toString.call(input) ===
'[object Date]';
57 function map(arr, fn) {
59 for (i = 0; i < arr.length; ++i) {
60 res.push(fn(arr[i], i));
65 function hasOwnProp(a, b) {
66 return Object.prototype.hasOwnProperty.call(a, b);
69 function extend(a, b) {
71 if (hasOwnProp(b, i)) {
76 if (hasOwnProp(b,
'toString')) {
77 a.toString = b.toString;
80 if (hasOwnProp(b,
'valueOf')) {
81 a.valueOf = b.valueOf;
87 function createUTC (input, format, locale, strict) {
88 return createLocalOrUTC(input, format, locale, strict,
true).utc();
91 function defaultParsingFlags() {
101 invalidFormat :
false,
102 userInvalidated :
false,
104 parsedDateParts : [],
107 weekdayMismatch :
false
111 function getParsingFlags(m) {
113 m._pf = defaultParsingFlags();
119 if (Array.prototype.some) {
120 some = Array.prototype.some;
122 some =
function (fun) {
123 var t = Object(
this);
124 var len = t.length >>> 0;
126 for (var i = 0; i < len; i++) {
127 if (i in t && fun.call(
this, t[i], i, t)) {
136 function isValid(m) {
137 if (m._isValid == null) {
138 var flags = getParsingFlags(m);
139 var parsedParts = some.call(flags.parsedDateParts, function (i) {
142 var isNowValid = !isNaN(m._d.getTime()) &&
143 flags.overflow < 0 &&
145 !flags.invalidMonth &&
146 !flags.invalidWeekday &&
147 !flags.weekdayMismatch &&
149 !flags.invalidFormat &&
150 !flags.userInvalidated &&
151 (!flags.meridiem || (flags.meridiem && parsedParts));
154 isNowValid = isNowValid &&
155 flags.charsLeftOver === 0 &&
156 flags.unusedTokens.length === 0 &&
157 flags.bigHour === undefined;
160 if (Object.isFrozen == null || !Object.isFrozen(m)) {
161 m._isValid = isNowValid;
170 function createInvalid (flags) {
171 var m = createUTC(NaN);
173 extend(getParsingFlags(m), flags);
176 getParsingFlags(m).userInvalidated =
true;
184 var momentProperties = hooks.momentProperties = [];
186 function copyConfig(to, from) {
189 if (!isUndefined(from._isAMomentObject)) {
190 to._isAMomentObject = from._isAMomentObject;
192 if (!isUndefined(from._i)) {
195 if (!isUndefined(from._f)) {
198 if (!isUndefined(from._l)) {
201 if (!isUndefined(from._strict)) {
202 to._strict = from._strict;
204 if (!isUndefined(from._tzm)) {
207 if (!isUndefined(from._isUTC)) {
208 to._isUTC = from._isUTC;
210 if (!isUndefined(from._offset)) {
211 to._offset = from._offset;
213 if (!isUndefined(from._pf)) {
214 to._pf = getParsingFlags(from);
216 if (!isUndefined(from._locale)) {
217 to._locale = from._locale;
220 if (momentProperties.length > 0) {
221 for (i = 0; i < momentProperties.length; i++) {
222 prop = momentProperties[i];
224 if (!isUndefined(val)) {
233 var updateInProgress =
false;
236 function Moment(config) {
237 copyConfig(
this, config);
238 this._d =
new Date(config._d != null ? config._d.getTime() : NaN);
239 if (!this.isValid()) {
240 this._d =
new Date(NaN);
244 if (updateInProgress ===
false) {
245 updateInProgress =
true;
246 hooks.updateOffset(
this);
247 updateInProgress =
false;
251 function isMoment (obj) {
252 return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
255 function absFloor (number) {
258 return Math.ceil(number) || 0;
260 return Math.floor(number);
264 function toInt(argumentForCoercion) {
265 var coercedNumber = +argumentForCoercion,
268 if (coercedNumber !== 0 && isFinite(coercedNumber)) {
269 value = absFloor(coercedNumber);
276 function compareArrays(array1, array2, dontConvert) {
277 var len = Math.min(array1.length, array2.length),
278 lengthDiff = Math.abs(array1.length - array2.length),
281 for (i = 0; i < len; i++) {
282 if ((dontConvert && array1[i] !== array2[i]) ||
283 (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
287 return diffs + lengthDiff;
291 if (hooks.suppressDeprecationWarnings ===
false &&
292 (typeof console !==
'undefined') && console.warn) {
293 console.warn(
'Deprecation warning: ' + msg);
297 function deprecate(msg, fn) {
298 var firstTime =
true;
300 return extend(
function () {
301 if (hooks.deprecationHandler != null) {
302 hooks.deprecationHandler(null, msg);
307 for (var i = 0; i < arguments.length; i++) {
309 if (typeof arguments[i] ===
'object') {
310 arg +=
'\n[' + i +
'] ';
311 for (var key in arguments[0]) {
312 arg += key +
': ' + arguments[0][key] +
', ';
314 arg = arg.slice(0, -2);
320 warn(msg +
'\nArguments: ' + Array.prototype.slice.call(args).join(
'') +
'\n' + (
new Error()).stack);
323 return fn.apply(
this, arguments);
327 var deprecations = {};
329 function deprecateSimple(name, msg) {
330 if (hooks.deprecationHandler != null) {
331 hooks.deprecationHandler(name, msg);
333 if (!deprecations[name]) {
335 deprecations[name] =
true;
339 hooks.suppressDeprecationWarnings =
false;
340 hooks.deprecationHandler = null;
342 function isFunction(input) {
343 return input instanceof Function || Object.prototype.toString.call(input) ===
'[object Function]';
346 function set (config) {
350 if (isFunction(prop)) {
353 this[
'_' + i] = prop;
356 this._config = config;
360 this._dayOfMonthOrdinalParseLenient =
new RegExp(
361 (this._dayOfMonthOrdinalParse.source ||
this._ordinalParse.source) +
362 '|' + (/\d{1,2}/).source);
365 function mergeConfigs(parentConfig, childConfig) {
366 var res = extend({}, parentConfig), prop;
367 for (prop in childConfig) {
368 if (hasOwnProp(childConfig, prop)) {
369 if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
371 extend(res[prop], parentConfig[prop]);
372 extend(res[prop], childConfig[prop]);
373 }
else if (childConfig[prop] != null) {
374 res[prop] = childConfig[prop];
380 for (prop in parentConfig) {
381 if (hasOwnProp(parentConfig, prop) &&
382 !hasOwnProp(childConfig, prop) &&
383 isObject(parentConfig[prop])) {
385 res[prop] = extend({}, res[prop]);
391 function Locale(config) {
392 if (config != null) {
402 keys =
function (obj) {
405 if (hasOwnProp(obj, i)) {
413 var defaultCalendar = {
414 sameDay :
'[Today at] LT',
415 nextDay :
'[Tomorrow at] LT',
416 nextWeek :
'dddd [at] LT',
417 lastDay :
'[Yesterday at] LT',
418 lastWeek :
'[Last] dddd [at] LT',
422 function calendar (key, mom, now) {
423 var output = this._calendar[key] || this._calendar[
'sameElse'];
424 return isFunction(output) ? output.call(mom, now) : output;
427 var defaultLongDateFormat = {
432 LLL :
'MMMM D, YYYY h:mm A',
433 LLLL :
'dddd, MMMM D, YYYY h:mm A'
436 function longDateFormat (key) {
437 var format = this._longDateFormat[key],
438 formatUpper = this._longDateFormat[key.toUpperCase()];
440 if (format || !formatUpper) {
444 this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g,
function (val) {
448 return this._longDateFormat[key];
451 var defaultInvalidDate =
'Invalid date';
453 function invalidDate () {
454 return this._invalidDate;
457 var defaultOrdinal =
'%d';
458 var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
460 function ordinal (number) {
461 return this._ordinal.replace(
'%d', number);
464 var defaultRelativeTime = {
481 function relativeTime (number, withoutSuffix,
string, isFuture) {
482 var output = this._relativeTime[string];
483 return (isFunction(output)) ?
484 output(number, withoutSuffix,
string, isFuture) :
485 output.replace(/%d/i, number);
488 function pastFuture (diff, output) {
489 var format = this._relativeTime[diff > 0 ?
'future' :
'past'];
490 return isFunction(format) ? format(output) : format.replace(/%s/i, output);
495 function addUnitAlias (unit, shorthand) {
496 var lowerCase = unit.toLowerCase();
497 aliases[lowerCase] = aliases[lowerCase +
's'] = aliases[shorthand] = unit;
500 function normalizeUnits(units) {
501 return typeof units ===
'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
504 function normalizeObjectUnits(inputObject) {
505 var normalizedInput = {},
509 for (prop in inputObject) {
510 if (hasOwnProp(inputObject, prop)) {
511 normalizedProp = normalizeUnits(prop);
512 if (normalizedProp) {
513 normalizedInput[normalizedProp] = inputObject[prop];
518 return normalizedInput;
523 function addUnitPriority(unit, priority) {
524 priorities[unit] = priority;
527 function getPrioritizedUnits(unitsObj) {
529 for (var u in unitsObj) {
530 units.push({unit: u, priority: priorities[u]});
532 units.sort(
function (a, b) {
533 return a.priority - b.priority;
538 function zeroFill(number, targetLength, forceSign) {
539 var absNumber =
'' + Math.abs(number),
540 zerosToFill = targetLength - absNumber.length,
542 return (sign ? (forceSign ?
'+' :
'') :
'-') +
543 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
546 var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|
do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
548 var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
550 var formatFunctions = {};
552 var formatTokenFunctions = {};
558 function addFormatToken (token, padded, ordinal, callback) {
560 if (typeof callback ===
'string') {
562 return this[callback]();
566 formatTokenFunctions[token] = func;
569 formatTokenFunctions[padded[0]] =
function () {
570 return zeroFill(func.apply(
this, arguments), padded[1], padded[2]);
574 formatTokenFunctions[ordinal] =
function () {
575 return this.localeData().ordinal(func.apply(
this, arguments), token);
580 function removeFormattingTokens(input) {
581 if (input.match(/\[[\s\S]/)) {
582 return input.replace(/^\[|\]$/g,
'');
584 return input.replace(/\\/g,
'');
587 function makeFormatFunction(format) {
588 var array = format.match(formattingTokens), i, length;
590 for (i = 0, length = array.length; i < length; i++) {
591 if (formatTokenFunctions[array[i]]) {
592 array[i] = formatTokenFunctions[array[i]];
594 array[i] = removeFormattingTokens(array[i]);
598 return function (mom) {
600 for (i = 0; i < length; i++) {
601 output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
608 function formatMoment(m, format) {
610 return m.localeData().invalidDate();
613 format = expandFormat(format, m.localeData());
614 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
616 return formatFunctions[format](m);
619 function expandFormat(format, locale) {
622 function replaceLongDateFormatTokens(input) {
623 return locale.longDateFormat(input) || input;
626 localFormattingTokens.lastIndex = 0;
627 while (i >= 0 && localFormattingTokens.test(format)) {
628 format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
629 localFormattingTokens.lastIndex = 0;
638 var match3 = /\d{3}/;
639 var match4 = /\d{4}/;
640 var match6 = /[+-]?\d{6}/;
641 var match1to2 = /\d\d?/;
642 var match3to4 = /\d\d\d\d?/;
643 var match5to6 = /\d\d\d\d\d\d?/;
644 var match1to3 = /\d{1,3}/;
645 var match1to4 = /\d{1,4}/;
646 var match1to6 = /[+-]?\d{1,6}/;
648 var matchUnsigned = /\d+/;
649 var matchSigned = /[+-]?\d+/;
651 var matchOffset = /Z|[+-]\d\d:?\d\d/gi;
652 var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi;
654 var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
658 var matchWord = /[0-9]{0,256}[
'a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
662 function addRegexToken (token, regex, strictRegex) {
663 regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
664 return (isStrict && strictRegex) ? strictRegex : regex;
668 function getParseRegexForToken (token, config) {
669 if (!hasOwnProp(regexes, token)) {
670 return new RegExp(unescapeFormat(token));
673 return regexes[token](config._strict, config._locale);
676 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
677 function unescapeFormat(s) {
678 return regexEscape(s.replace('\\
', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
679 return p1 || p2 || p3 || p4;
683 function regexEscape(s) {
684 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&
');
689 function addParseToken (token, callback) {
690 var i, func = callback;
691 if (typeof token === 'string') {
694 if (isNumber(callback)) {
695 func = function (input, array) {
696 array[callback] = toInt(input);
699 for (i = 0; i < token.length; i++) {
700 tokens[token[i]] = func;
704 function addWeekParseToken (token, callback) {
705 addParseToken(token, function (input, array, config, token) {
706 config._w = config._w || {};
707 callback(input, config._w, config, token);
711 function addTimeToArrayFromToken(token, input, config) {
712 if (input != null && hasOwnProp(tokens, token)) {
713 tokens[token](input, config._a, config, token);
729 addFormatToken('Y
', 0, 0, function () {
731 return y <= 9999 ? '' + y : '+
' + y;
734 addFormatToken(0, ['YY
', 2], 0, function () {
735 return this.year() % 100;
738 addFormatToken(0, ['YYYY
', 4], 0, 'year
');
739 addFormatToken(0, ['YYYYY
', 5], 0, 'year
');
740 addFormatToken(0, ['YYYYYY
', 6, true], 0, 'year
');
744 addUnitAlias('year
', 'y
');
748 addUnitPriority('year
', 1);
752 addRegexToken('Y
', matchSigned);
753 addRegexToken('YY
', match1to2, match2);
754 addRegexToken('YYYY
', match1to4, match4);
755 addRegexToken('YYYYY
', match1to6, match6);
756 addRegexToken('YYYYYY
', match1to6, match6);
758 addParseToken(['YYYYY
', 'YYYYYY
'], YEAR);
759 addParseToken('YYYY
', function (input, array) {
760 array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
762 addParseToken('YY
', function (input, array) {
763 array[YEAR] = hooks.parseTwoDigitYear(input);
765 addParseToken('Y
', function (input, array) {
766 array[YEAR] = parseInt(input, 10);
771 function daysInYear(year) {
772 return isLeapYear(year) ? 366 : 365;
775 function isLeapYear(year) {
776 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
781 hooks.parseTwoDigitYear = function (input) {
782 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
787 var getSetYear = makeGetSet('FullYear
', true);
789 function getIsLeapYear () {
790 return isLeapYear(this.year());
793 function makeGetSet (unit, keepTime) {
794 return function (value) {
796 set$1(this, unit, value);
797 hooks.updateOffset(this, keepTime);
800 return get(this, unit);
805 function get (mom, unit) {
806 return mom.isValid() ?
807 mom._d['get' + (mom._isUTC ? 'UTC
' : '') + unit]() : NaN;
810 function set$1 (mom, unit, value) {
811 if (mom.isValid() && !isNaN(value)) {
812 if (unit === 'FullYear
' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
813 mom._d['set
' + (mom._isUTC ? 'UTC
' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
816 mom._d['set
' + (mom._isUTC ? 'UTC
' : '') + unit](value);
823 function stringGet (units) {
824 units = normalizeUnits(units);
825 if (isFunction(this[units])) {
826 return this[units]();
832 function stringSet (units, value) {
833 if (typeof units === 'object') {
834 units = normalizeObjectUnits(units);
835 var prioritized = getPrioritizedUnits(units);
836 for (var i = 0; i < prioritized.length; i++) {
837 this[prioritized[i].unit](units[prioritized[i].unit]);
840 units = normalizeUnits(units);
841 if (isFunction(this[units])) {
842 return this[units](value);
849 return ((n % x) + x) % x;
854 if (Array.prototype.indexOf) {
855 indexOf = Array.prototype.indexOf;
857 indexOf = function (o) {
860 for (i = 0; i < this.length; ++i) {
869 function daysInMonth(year, month) {
870 if (isNaN(year) || isNaN(month)) {
873 var modMonth = mod(month, 12);
874 year += (month - modMonth) / 12;
875 return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
880 addFormatToken('M
', ['MM
', 2], 'Mo
', function () {
881 return this.month() + 1;
884 addFormatToken('MMM
', 0, 0, function (format) {
885 return this.localeData().monthsShort(this, format);
888 addFormatToken('MMMM
', 0, 0, function (format) {
889 return this.localeData().months(this, format);
894 addUnitAlias('month
', 'M
');
898 addUnitPriority('month
', 8);
902 addRegexToken('M
', match1to2);
903 addRegexToken('MM
', match1to2, match2);
904 addRegexToken('MMM
', function (isStrict, locale) {
905 return locale.monthsShortRegex(isStrict);
907 addRegexToken('MMMM
', function (isStrict, locale) {
908 return locale.monthsRegex(isStrict);
911 addParseToken(['M
', 'MM
'], function (input, array) {
912 array[MONTH] = toInt(input) - 1;
915 addParseToken(['MMM
', 'MMMM
'], function (input, array, config, token) {
916 var month = config._locale.monthsParse(input, token, config._strict);
917 // if we didn't find a month name, mark the date as invalid.
919 array[MONTH] = month;
921 getParsingFlags(config).invalidMonth = input;
927 var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
928 var defaultLocaleMonths =
'January_February_March_April_May_June_July_August_September_October_November_December'.split(
'_');
929 function localeMonths (m, format) {
931 return isArray(this._months) ? this._months :
932 this._months[
'standalone'];
934 return isArray(this._months) ? this._months[m.month()] :
935 this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ?
'format' :
'standalone'][m.month()];
938 var defaultLocaleMonthsShort =
'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
'_');
939 function localeMonthsShort (m, format) {
941 return isArray(this._monthsShort) ? this._monthsShort :
942 this._monthsShort[
'standalone'];
944 return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
945 this._monthsShort[MONTHS_IN_FORMAT.test(format) ?
'format' :
'standalone'][m.month()];
948 function handleStrictParse(monthName, format, strict) {
949 var i, ii, mom, llc = monthName.toLocaleLowerCase();
950 if (!this._monthsParse) {
952 this._monthsParse = [];
953 this._longMonthsParse = [];
954 this._shortMonthsParse = [];
955 for (i = 0; i < 12; ++i) {
956 mom = createUTC([2000, i]);
957 this._shortMonthsParse[i] = this.monthsShort(mom,
'').toLocaleLowerCase();
958 this._longMonthsParse[i] = this.months(mom,
'').toLocaleLowerCase();
963 if (format ===
'MMM') {
964 ii = indexOf.call(this._shortMonthsParse, llc);
965 return ii !== -1 ? ii : null;
967 ii = indexOf.call(this._longMonthsParse, llc);
968 return ii !== -1 ? ii : null;
971 if (format ===
'MMM') {
972 ii = indexOf.call(this._shortMonthsParse, llc);
976 ii = indexOf.call(this._longMonthsParse, llc);
977 return ii !== -1 ? ii : null;
979 ii = indexOf.call(this._longMonthsParse, llc);
983 ii = indexOf.call(this._shortMonthsParse, llc);
984 return ii !== -1 ? ii : null;
989 function localeMonthsParse (monthName, format, strict) {
992 if (this._monthsParseExact) {
993 return handleStrictParse.call(
this, monthName, format, strict);
996 if (!this._monthsParse) {
997 this._monthsParse = [];
998 this._longMonthsParse = [];
999 this._shortMonthsParse = [];
1005 for (i = 0; i < 12; i++) {
1007 mom = createUTC([2000, i]);
1008 if (strict && !this._longMonthsParse[i]) {
1009 this._longMonthsParse[i] =
new RegExp(
'^' + this.months(mom,
'').replace(
'.',
'') +
'$',
'i');
1010 this._shortMonthsParse[i] =
new RegExp(
'^' + this.monthsShort(mom,
'').replace(
'.',
'') +
'$',
'i');
1012 if (!strict && !this._monthsParse[i]) {
1013 regex =
'^' + this.months(mom,
'') +
'|^' + this.monthsShort(mom,
'');
1014 this._monthsParse[i] =
new RegExp(regex.replace(
'.',
''),
'i');
1017 if (strict && format ===
'MMMM' && this._longMonthsParse[i].test(monthName)) {
1019 }
else if (strict && format ===
'MMM' && this._shortMonthsParse[i].test(monthName)) {
1021 }
else if (!strict && this._monthsParse[i].test(monthName)) {
1029 function setMonth (mom, value) {
1032 if (!mom.isValid()) {
1037 if (typeof value ===
'string') {
1038 if (/^\d+$/.test(value)) {
1039 value = toInt(value);
1041 value = mom.localeData().monthsParse(value);
1043 if (!isNumber(value)) {
1049 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
1050 mom._d[
'set' + (mom._isUTC ?
'UTC' :
'') +
'Month'](value, dayOfMonth);
1054 function getSetMonth (value) {
1055 if (value != null) {
1056 setMonth(
this, value);
1057 hooks.updateOffset(
this,
true);
1060 return get(
this,
'Month');
1064 function getDaysInMonth () {
1065 return daysInMonth(this.year(), this.month());
1068 var defaultMonthsShortRegex = matchWord;
1069 function monthsShortRegex (isStrict) {
1070 if (this._monthsParseExact) {
1071 if (!hasOwnProp(
this,
'_monthsRegex')) {
1072 computeMonthsParse.call(
this);
1075 return this._monthsShortStrictRegex;
1077 return this._monthsShortRegex;
1080 if (!hasOwnProp(
this,
'_monthsShortRegex')) {
1081 this._monthsShortRegex = defaultMonthsShortRegex;
1083 return this._monthsShortStrictRegex && isStrict ?
1084 this._monthsShortStrictRegex : this._monthsShortRegex;
1088 var defaultMonthsRegex = matchWord;
1089 function monthsRegex (isStrict) {
1090 if (this._monthsParseExact) {
1091 if (!hasOwnProp(
this,
'_monthsRegex')) {
1092 computeMonthsParse.call(
this);
1095 return this._monthsStrictRegex;
1097 return this._monthsRegex;
1100 if (!hasOwnProp(
this,
'_monthsRegex')) {
1101 this._monthsRegex = defaultMonthsRegex;
1103 return this._monthsStrictRegex && isStrict ?
1104 this._monthsStrictRegex : this._monthsRegex;
1108 function computeMonthsParse () {
1109 function cmpLenRev(a, b) {
1110 return b.length - a.length;
1113 var shortPieces = [], longPieces = [], mixedPieces = [],
1115 for (i = 0; i < 12; i++) {
1117 mom = createUTC([2000, i]);
1118 shortPieces.push(this.monthsShort(mom,
''));
1119 longPieces.push(this.months(mom,
''));
1120 mixedPieces.push(this.months(mom,
''));
1121 mixedPieces.push(this.monthsShort(mom,
''));
1125 shortPieces.sort(cmpLenRev);
1126 longPieces.sort(cmpLenRev);
1127 mixedPieces.sort(cmpLenRev);
1128 for (i = 0; i < 12; i++) {
1129 shortPieces[i] = regexEscape(shortPieces[i]);
1130 longPieces[i] = regexEscape(longPieces[i]);
1132 for (i = 0; i < 24; i++) {
1133 mixedPieces[i] = regexEscape(mixedPieces[i]);
1136 this._monthsRegex =
new RegExp(
'^(' + mixedPieces.join(
'|') +
')',
'i');
1137 this._monthsShortRegex = this._monthsRegex;
1138 this._monthsStrictRegex =
new RegExp(
'^(' + longPieces.join(
'|') +
')',
'i');
1139 this._monthsShortStrictRegex =
new RegExp(
'^(' + shortPieces.join(
'|') +
')',
'i');
1142 function createDate (y, m, d, h, M, s, ms) {
1147 if (y < 100 && y >= 0) {
1149 date =
new Date(y + 400, m, d, h, M, s, ms);
1150 if (isFinite(date.getFullYear())) {
1151 date.setFullYear(y);
1154 date =
new Date(y, m, d, h, M, s, ms);
1160 function createUTCDate (y) {
1163 if (y < 100 && y >= 0) {
1164 var args = Array.prototype.slice.call(arguments);
1167 date =
new Date(Date.UTC.apply(null, args));
1168 if (isFinite(date.getUTCFullYear())) {
1169 date.setUTCFullYear(y);
1172 date =
new Date(Date.UTC.apply(null, arguments));
1179 function firstWeekOffset(year, dow, doy) {
1181 fwd = 7 + dow - doy,
1183 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
1185 return -fwdlw + fwd - 1;
1189 function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
1190 var localWeekday = (7 + weekday - dow) % 7,
1191 weekOffset = firstWeekOffset(year, dow, doy),
1192 dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
1193 resYear, resDayOfYear;
1195 if (dayOfYear <= 0) {
1197 resDayOfYear = daysInYear(resYear) + dayOfYear;
1198 }
else if (dayOfYear > daysInYear(year)) {
1200 resDayOfYear = dayOfYear - daysInYear(year);
1203 resDayOfYear = dayOfYear;
1208 dayOfYear: resDayOfYear
1212 function weekOfYear(mom, dow, doy) {
1213 var weekOffset = firstWeekOffset(mom.year(), dow, doy),
1214 week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
1218 resYear = mom.year() - 1;
1219 resWeek = week + weeksInYear(resYear, dow, doy);
1220 }
else if (week > weeksInYear(mom.year(), dow, doy)) {
1221 resWeek = week - weeksInYear(mom.year(), dow, doy);
1222 resYear = mom.year() + 1;
1224 resYear = mom.year();
1234 function weeksInYear(year, dow, doy) {
1235 var weekOffset = firstWeekOffset(year, dow, doy),
1236 weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
1237 return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
1242 addFormatToken(
'w', [
'ww', 2],
'wo',
'week');
1243 addFormatToken(
'W', [
'WW', 2],
'Wo',
'isoWeek');
1247 addUnitAlias(
'week',
'w');
1248 addUnitAlias(
'isoWeek',
'W');
1252 addUnitPriority(
'week', 5);
1253 addUnitPriority(
'isoWeek', 5);
1257 addRegexToken(
'w', match1to2);
1258 addRegexToken(
'ww', match1to2, match2);
1259 addRegexToken(
'W', match1to2);
1260 addRegexToken(
'WW', match1to2, match2);
1262 addWeekParseToken([
'w',
'ww',
'W',
'WW'],
function (input, week, config, token) {
1263 week[token.substr(0, 1)] = toInt(input);
1270 function localeWeek (mom) {
1271 return weekOfYear(mom, this._week.dow,
this._week.doy).week;
1274 var defaultLocaleWeek = {
1279 function localeFirstDayOfWeek () {
1280 return this._week.dow;
1283 function localeFirstDayOfYear () {
1284 return this._week.doy;
1289 function getSetWeek (input) {
1290 var week = this.localeData().week(
this);
1291 return input == null ? week : this.add((input - week) * 7,
'd');
1294 function getSetISOWeek (input) {
1295 var week = weekOfYear(
this, 1, 4).week;
1296 return input == null ? week : this.add((input - week) * 7,
'd');
1301 addFormatToken(
'd', 0,
'do',
'day');
1303 addFormatToken(
'dd', 0, 0,
function (format) {
1304 return this.localeData().weekdaysMin(
this, format);
1307 addFormatToken(
'ddd', 0, 0,
function (format) {
1308 return this.localeData().weekdaysShort(
this, format);
1311 addFormatToken(
'dddd', 0, 0,
function (format) {
1312 return this.localeData().weekdays(
this, format);
1315 addFormatToken(
'e', 0, 0,
'weekday');
1316 addFormatToken(
'E', 0, 0,
'isoWeekday');
1320 addUnitAlias(
'day',
'd');
1321 addUnitAlias(
'weekday',
'e');
1322 addUnitAlias(
'isoWeekday',
'E');
1325 addUnitPriority(
'day', 11);
1326 addUnitPriority(
'weekday', 11);
1327 addUnitPriority(
'isoWeekday', 11);
1331 addRegexToken(
'd', match1to2);
1332 addRegexToken(
'e', match1to2);
1333 addRegexToken(
'E', match1to2);
1334 addRegexToken(
'dd',
function (isStrict, locale) {
1335 return locale.weekdaysMinRegex(isStrict);
1337 addRegexToken(
'ddd',
function (isStrict, locale) {
1338 return locale.weekdaysShortRegex(isStrict);
1340 addRegexToken(
'dddd',
function (isStrict, locale) {
1341 return locale.weekdaysRegex(isStrict);
1344 addWeekParseToken([
'dd',
'ddd',
'dddd'],
function (input, week, config, token) {
1345 var weekday = config._locale.weekdaysParse(input, token, config._strict);
1347 if (weekday != null) {
1350 getParsingFlags(config).invalidWeekday = input;
1354 addWeekParseToken([
'd',
'e',
'E'],
function (input, week, config, token) {
1355 week[token] = toInt(input);
1360 function parseWeekday(input, locale) {
1361 if (typeof input !==
'string') {
1365 if (!isNaN(input)) {
1366 return parseInt(input, 10);
1369 input = locale.weekdaysParse(input);
1370 if (typeof input ===
'number') {
1377 function parseIsoWeekday(input, locale) {
1378 if (typeof input ===
'string') {
1379 return locale.weekdaysParse(input) % 7 || 7;
1381 return isNaN(input) ? null : input;
1385 function shiftWeekdays (ws, n) {
1386 return ws.slice(n, 7).concat(ws.slice(0, n));
1389 var defaultLocaleWeekdays =
'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
'_');
1390 function localeWeekdays (m, format) {
1391 var weekdays = isArray(this._weekdays) ? this._weekdays :
1392 this._weekdays[(m && m !==
true && this._weekdays.isFormat.test(format)) ?
'format' :
'standalone'];
1393 return (m ===
true) ? shiftWeekdays(weekdays, this._week.dow)
1394 : (m) ? weekdays[m.day()] : weekdays;
1397 var defaultLocaleWeekdaysShort =
'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split(
'_');
1398 function localeWeekdaysShort (m) {
1399 return (m ===
true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
1400 : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
1403 var defaultLocaleWeekdaysMin =
'Su_Mo_Tu_We_Th_Fr_Sa'.split(
'_');
1404 function localeWeekdaysMin (m) {
1405 return (m ===
true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
1406 : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
1409 function handleStrictParse$1(weekdayName, format, strict) {
1410 var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
1411 if (!this._weekdaysParse) {
1412 this._weekdaysParse = [];
1413 this._shortWeekdaysParse = [];
1414 this._minWeekdaysParse = [];
1416 for (i = 0; i < 7; ++i) {
1417 mom = createUTC([2000, 1]).day(i);
1418 this._minWeekdaysParse[i] = this.weekdaysMin(mom,
'').toLocaleLowerCase();
1419 this._shortWeekdaysParse[i] = this.weekdaysShort(mom,
'').toLocaleLowerCase();
1420 this._weekdaysParse[i] = this.weekdays(mom,
'').toLocaleLowerCase();
1425 if (format ===
'dddd') {
1426 ii = indexOf.call(this._weekdaysParse, llc);
1427 return ii !== -1 ? ii : null;
1428 }
else if (format ===
'ddd') {
1429 ii = indexOf.call(this._shortWeekdaysParse, llc);
1430 return ii !== -1 ? ii : null;
1432 ii = indexOf.call(this._minWeekdaysParse, llc);
1433 return ii !== -1 ? ii : null;
1436 if (format ===
'dddd') {
1437 ii = indexOf.call(this._weekdaysParse, llc);
1441 ii = indexOf.call(this._shortWeekdaysParse, llc);
1445 ii = indexOf.call(this._minWeekdaysParse, llc);
1446 return ii !== -1 ? ii : null;
1447 }
else if (format ===
'ddd') {
1448 ii = indexOf.call(this._shortWeekdaysParse, llc);
1452 ii = indexOf.call(this._weekdaysParse, llc);
1456 ii = indexOf.call(this._minWeekdaysParse, llc);
1457 return ii !== -1 ? ii : null;
1459 ii = indexOf.call(this._minWeekdaysParse, llc);
1463 ii = indexOf.call(this._weekdaysParse, llc);
1467 ii = indexOf.call(this._shortWeekdaysParse, llc);
1468 return ii !== -1 ? ii : null;
1473 function localeWeekdaysParse (weekdayName, format, strict) {
1476 if (this._weekdaysParseExact) {
1477 return handleStrictParse$1.call(
this, weekdayName, format, strict);
1480 if (!this._weekdaysParse) {
1481 this._weekdaysParse = [];
1482 this._minWeekdaysParse = [];
1483 this._shortWeekdaysParse = [];
1484 this._fullWeekdaysParse = [];
1487 for (i = 0; i < 7; i++) {
1490 mom = createUTC([2000, 1]).day(i);
1491 if (strict && !this._fullWeekdaysParse[i]) {
1492 this._fullWeekdaysParse[i] =
new RegExp(
'^' + this.weekdays(mom,
'').replace(
'.',
'\\.?') +
'$',
'i');
1493 this._shortWeekdaysParse[i] =
new RegExp(
'^' + this.weekdaysShort(mom,
'').replace(
'.',
'\\.?') +
'$',
'i');
1494 this._minWeekdaysParse[i] =
new RegExp(
'^' + this.weekdaysMin(mom,
'').replace(
'.',
'\\.?') +
'$',
'i');
1496 if (!this._weekdaysParse[i]) {
1497 regex =
'^' + this.weekdays(mom,
'') +
'|^' + this.weekdaysShort(mom,
'') +
'|^' + this.weekdaysMin(mom,
'');
1498 this._weekdaysParse[i] =
new RegExp(regex.replace(
'.',
''),
'i');
1501 if (strict && format ===
'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
1503 }
else if (strict && format ===
'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
1505 }
else if (strict && format ===
'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
1507 }
else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
1515 function getSetDayOfWeek (input) {
1516 if (!this.isValid()) {
1517 return input != null ?
this : NaN;
1519 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
1520 if (input != null) {
1521 input = parseWeekday(input, this.localeData());
1522 return this.add(input - day,
'd');
1528 function getSetLocaleDayOfWeek (input) {
1529 if (!this.isValid()) {
1530 return input != null ?
this : NaN;
1532 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
1533 return input == null ? weekday : this.add(input - weekday,
'd');
1536 function getSetISODayOfWeek (input) {
1537 if (!this.isValid()) {
1538 return input != null ?
this : NaN;
1545 if (input != null) {
1546 var weekday = parseIsoWeekday(input, this.localeData());
1547 return this.day(this.day() % 7 ? weekday : weekday - 7);
1549 return this.day() || 7;
1553 var defaultWeekdaysRegex = matchWord;
1554 function weekdaysRegex (isStrict) {
1555 if (this._weekdaysParseExact) {
1556 if (!hasOwnProp(
this,
'_weekdaysRegex')) {
1557 computeWeekdaysParse.call(
this);
1560 return this._weekdaysStrictRegex;
1562 return this._weekdaysRegex;
1565 if (!hasOwnProp(
this,
'_weekdaysRegex')) {
1566 this._weekdaysRegex = defaultWeekdaysRegex;
1568 return this._weekdaysStrictRegex && isStrict ?
1569 this._weekdaysStrictRegex : this._weekdaysRegex;
1573 var defaultWeekdaysShortRegex = matchWord;
1574 function weekdaysShortRegex (isStrict) {
1575 if (this._weekdaysParseExact) {
1576 if (!hasOwnProp(
this,
'_weekdaysRegex')) {
1577 computeWeekdaysParse.call(
this);
1580 return this._weekdaysShortStrictRegex;
1582 return this._weekdaysShortRegex;
1585 if (!hasOwnProp(
this,
'_weekdaysShortRegex')) {
1586 this._weekdaysShortRegex = defaultWeekdaysShortRegex;
1588 return this._weekdaysShortStrictRegex && isStrict ?
1589 this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
1593 var defaultWeekdaysMinRegex = matchWord;
1594 function weekdaysMinRegex (isStrict) {
1595 if (this._weekdaysParseExact) {
1596 if (!hasOwnProp(
this,
'_weekdaysRegex')) {
1597 computeWeekdaysParse.call(
this);
1600 return this._weekdaysMinStrictRegex;
1602 return this._weekdaysMinRegex;
1605 if (!hasOwnProp(
this,
'_weekdaysMinRegex')) {
1606 this._weekdaysMinRegex = defaultWeekdaysMinRegex;
1608 return this._weekdaysMinStrictRegex && isStrict ?
1609 this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
1614 function computeWeekdaysParse () {
1615 function cmpLenRev(a, b) {
1616 return b.length - a.length;
1619 var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
1620 i, mom, minp, shortp, longp;
1621 for (i = 0; i < 7; i++) {
1623 mom = createUTC([2000, 1]).day(i);
1624 minp = this.weekdaysMin(mom,
'');
1625 shortp = this.weekdaysShort(mom,
'');
1626 longp = this.weekdays(mom,
'');
1627 minPieces.push(minp);
1628 shortPieces.push(shortp);
1629 longPieces.push(longp);
1630 mixedPieces.push(minp);
1631 mixedPieces.push(shortp);
1632 mixedPieces.push(longp);
1636 minPieces.sort(cmpLenRev);
1637 shortPieces.sort(cmpLenRev);
1638 longPieces.sort(cmpLenRev);
1639 mixedPieces.sort(cmpLenRev);
1640 for (i = 0; i < 7; i++) {
1641 shortPieces[i] = regexEscape(shortPieces[i]);
1642 longPieces[i] = regexEscape(longPieces[i]);
1643 mixedPieces[i] = regexEscape(mixedPieces[i]);
1646 this._weekdaysRegex =
new RegExp(
'^(' + mixedPieces.join(
'|') +
')',
'i');
1647 this._weekdaysShortRegex = this._weekdaysRegex;
1648 this._weekdaysMinRegex = this._weekdaysRegex;
1650 this._weekdaysStrictRegex =
new RegExp(
'^(' + longPieces.join(
'|') +
')',
'i');
1651 this._weekdaysShortStrictRegex =
new RegExp(
'^(' + shortPieces.join(
'|') +
')',
'i');
1652 this._weekdaysMinStrictRegex =
new RegExp(
'^(' + minPieces.join(
'|') +
')',
'i');
1657 function hFormat() {
1658 return this.hours() % 12 || 12;
1661 function kFormat() {
1662 return this.hours() || 24;
1665 addFormatToken(
'H', [
'HH', 2], 0,
'hour');
1666 addFormatToken(
'h', [
'hh', 2], 0, hFormat);
1667 addFormatToken(
'k', [
'kk', 2], 0, kFormat);
1669 addFormatToken(
'hmm', 0, 0,
function () {
1670 return '' + hFormat.apply(
this) + zeroFill(this.minutes(), 2);
1673 addFormatToken(
'hmmss', 0, 0,
function () {
1674 return '' + hFormat.apply(
this) + zeroFill(this.minutes(), 2) +
1675 zeroFill(this.seconds(), 2);
1678 addFormatToken(
'Hmm', 0, 0,
function () {
1679 return '' + this.hours() + zeroFill(this.minutes(), 2);
1682 addFormatToken(
'Hmmss', 0, 0,
function () {
1683 return '' + this.hours() + zeroFill(this.minutes(), 2) +
1684 zeroFill(this.seconds(), 2);
1687 function meridiem (token, lowercase) {
1688 addFormatToken(token, 0, 0,
function () {
1689 return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
1693 meridiem(
'a',
true);
1694 meridiem(
'A',
false);
1698 addUnitAlias(
'hour',
'h');
1701 addUnitPriority(
'hour', 13);
1705 function matchMeridiem (isStrict, locale) {
1706 return locale._meridiemParse;
1709 addRegexToken(
'a', matchMeridiem);
1710 addRegexToken(
'A', matchMeridiem);
1711 addRegexToken(
'H', match1to2);
1712 addRegexToken(
'h', match1to2);
1713 addRegexToken(
'k', match1to2);
1714 addRegexToken(
'HH', match1to2, match2);
1715 addRegexToken(
'hh', match1to2, match2);
1716 addRegexToken(
'kk', match1to2, match2);
1718 addRegexToken(
'hmm', match3to4);
1719 addRegexToken(
'hmmss', match5to6);
1720 addRegexToken(
'Hmm', match3to4);
1721 addRegexToken(
'Hmmss', match5to6);
1723 addParseToken([
'H',
'HH'], HOUR);
1724 addParseToken([
'k',
'kk'],
function (input, array, config) {
1725 var kInput = toInt(input);
1726 array[HOUR] = kInput === 24 ? 0 : kInput;
1728 addParseToken([
'a',
'A'],
function (input, array, config) {
1729 config._isPm = config._locale.isPM(input);
1730 config._meridiem = input;
1732 addParseToken([
'h',
'hh'],
function (input, array, config) {
1733 array[HOUR] = toInt(input);
1734 getParsingFlags(config).bigHour =
true;
1736 addParseToken(
'hmm',
function (input, array, config) {
1737 var pos = input.length - 2;
1738 array[HOUR] = toInt(input.substr(0, pos));
1739 array[MINUTE] = toInt(input.substr(pos));
1740 getParsingFlags(config).bigHour =
true;
1742 addParseToken(
'hmmss',
function (input, array, config) {
1743 var pos1 = input.length - 4;
1744 var pos2 = input.length - 2;
1745 array[HOUR] = toInt(input.substr(0, pos1));
1746 array[MINUTE] = toInt(input.substr(pos1, 2));
1747 array[SECOND] = toInt(input.substr(pos2));
1748 getParsingFlags(config).bigHour =
true;
1750 addParseToken(
'Hmm',
function (input, array, config) {
1751 var pos = input.length - 2;
1752 array[HOUR] = toInt(input.substr(0, pos));
1753 array[MINUTE] = toInt(input.substr(pos));
1755 addParseToken(
'Hmmss',
function (input, array, config) {
1756 var pos1 = input.length - 4;
1757 var pos2 = input.length - 2;
1758 array[HOUR] = toInt(input.substr(0, pos1));
1759 array[MINUTE] = toInt(input.substr(pos1, 2));
1760 array[SECOND] = toInt(input.substr(pos2));
1765 function localeIsPM (input) {
1768 return ((input +
'').toLowerCase().charAt(0) ===
'p');
1771 var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
1772 function localeMeridiem (hours, minutes, isLower) {
1774 return isLower ?
'pm' :
'PM';
1776 return isLower ?
'am' :
'AM';
1787 var getSetHour = makeGetSet(
'Hours',
true);
1790 calendar: defaultCalendar,
1791 longDateFormat: defaultLongDateFormat,
1792 invalidDate: defaultInvalidDate,
1793 ordinal: defaultOrdinal,
1794 dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
1795 relativeTime: defaultRelativeTime,
1797 months: defaultLocaleMonths,
1798 monthsShort: defaultLocaleMonthsShort,
1800 week: defaultLocaleWeek,
1802 weekdays: defaultLocaleWeekdays,
1803 weekdaysMin: defaultLocaleWeekdaysMin,
1804 weekdaysShort: defaultLocaleWeekdaysShort,
1806 meridiemParse: defaultLocaleMeridiemParse
1811 var localeFamilies = {};
1814 function normalizeLocale(key) {
1815 return key ? key.toLowerCase().replace(
'_',
'-') : key;
1821 function chooseLocale(names) {
1822 var i = 0, j, next, locale, split;
1824 while (i < names.length) {
1825 split = normalizeLocale(names[i]).split(
'-');
1827 next = normalizeLocale(names[i + 1]);
1828 next = next ? next.split(
'-') : null;
1830 locale = loadLocale(split.slice(0, j).join(
'-'));
1834 if (next && next.length >= j && compareArrays(split, next,
true) >= j - 1) {
1842 return globalLocale;
1845 function loadLocale(name) {
1846 var oldLocale = null;
1848 if (!locales[name] && (typeof module !==
'undefined') &&
1849 module && module.exports) {
1851 oldLocale = globalLocale._abbr;
1852 var aliasedRequire = require;
1853 aliasedRequire(
'./locale/' + name);
1854 getSetGlobalLocale(oldLocale);
1857 return locales[name];
1863 function getSetGlobalLocale (key, values) {
1866 if (isUndefined(values)) {
1867 data = getLocale(key);
1870 data = defineLocale(key, values);
1875 globalLocale = data;
1878 if ((typeof console !==
'undefined') && console.warn) {
1880 console.warn(
'Locale ' + key +
' not found. Did you forget to load it?');
1885 return globalLocale._abbr;
1888 function defineLocale (name, config) {
1889 if (config !== null) {
1890 var locale, parentConfig = baseConfig;
1892 if (locales[name] != null) {
1893 deprecateSimple(
'defineLocaleOverride',
1894 'use moment.updateLocale(localeName, config) to change ' +
1895 'an existing locale. moment.defineLocale(localeName, ' +
1896 'config) should only be used for creating a new locale ' +
1897 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
1898 parentConfig = locales[name]._config;
1899 }
else if (config.parentLocale != null) {
1900 if (locales[config.parentLocale] != null) {
1901 parentConfig = locales[config.parentLocale]._config;
1903 locale = loadLocale(config.parentLocale);
1904 if (locale != null) {
1905 parentConfig = locale._config;
1907 if (!localeFamilies[config.parentLocale]) {
1908 localeFamilies[config.parentLocale] = [];
1910 localeFamilies[config.parentLocale].push({
1918 locales[name] =
new Locale(mergeConfigs(parentConfig, config));
1920 if (localeFamilies[name]) {
1921 localeFamilies[name].forEach(
function (x) {
1922 defineLocale(x.name, x.config);
1929 getSetGlobalLocale(name);
1932 return locales[name];
1935 delete locales[name];
1940 function updateLocale(name, config) {
1941 if (config != null) {
1942 var locale, tmpLocale, parentConfig = baseConfig;
1944 tmpLocale = loadLocale(name);
1945 if (tmpLocale != null) {
1946 parentConfig = tmpLocale._config;
1948 config = mergeConfigs(parentConfig, config);
1949 locale =
new Locale(config);
1950 locale.parentLocale = locales[name];
1951 locales[name] = locale;
1954 getSetGlobalLocale(name);
1957 if (locales[name] != null) {
1958 if (locales[name].parentLocale != null) {
1959 locales[name] = locales[name].parentLocale;
1960 }
else if (locales[name] != null) {
1961 delete locales[name];
1965 return locales[name];
1969 function getLocale (key) {
1972 if (key && key._locale && key._locale._abbr) {
1973 key = key._locale._abbr;
1977 return globalLocale;
1980 if (!isArray(key)) {
1982 locale = loadLocale(key);
1989 return chooseLocale(key);
1992 function listLocales() {
1993 return keys(locales);
1996 function checkOverflow (m) {
2000 if (a && getParsingFlags(m).overflow === -2) {
2002 a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
2003 a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
2004 a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
2005 a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
2006 a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
2007 a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
2010 if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
2013 if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
2016 if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
2020 getParsingFlags(m).overflow = overflow;
2027 function defaults(a, b, c) {
2037 function currentDateArray(config) {
2039 var nowValue =
new Date(hooks.now());
2040 if (config._useUTC) {
2041 return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
2043 return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
2050 function configFromArray (config) {
2051 var i, date, input = [], currentDate, expectedWeekday, yearToUse;
2057 currentDate = currentDateArray(config);
2060 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
2061 dayOfYearFromWeekInfo(config);
2065 if (config._dayOfYear != null) {
2066 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
2068 if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
2069 getParsingFlags(config)._overflowDayOfYear =
true;
2072 date = createUTCDate(yearToUse, 0, config._dayOfYear);
2073 config._a[MONTH] = date.getUTCMonth();
2074 config._a[DATE] = date.getUTCDate();
2082 for (i = 0; i < 3 && config._a[i] == null; ++i) {
2083 config._a[i] = input[i] = currentDate[i];
2087 for (; i < 7; i++) {
2088 config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
2092 if (config._a[HOUR] === 24 &&
2093 config._a[MINUTE] === 0 &&
2094 config._a[SECOND] === 0 &&
2095 config._a[MILLISECOND] === 0) {
2096 config._nextDay =
true;
2097 config._a[HOUR] = 0;
2100 config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
2101 expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
2105 if (config._tzm != null) {
2106 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
2109 if (config._nextDay) {
2110 config._a[HOUR] = 24;
2114 if (config._w && typeof config._w.d !==
'undefined' && config._w.d !== expectedWeekday) {
2115 getParsingFlags(config).weekdayMismatch =
true;
2119 function dayOfYearFromWeekInfo(config) {
2120 var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
2123 if (w.GG != null || w.W != null || w.E != null) {
2131 weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
2132 week = defaults(w.W, 1);
2133 weekday = defaults(w.E, 1);
2134 if (weekday < 1 || weekday > 7) {
2135 weekdayOverflow =
true;
2138 dow = config._locale._week.dow;
2139 doy = config._locale._week.doy;
2141 var curWeek = weekOfYear(createLocal(), dow, doy);
2143 weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
2146 week = defaults(w.w, curWeek.week);
2151 if (weekday < 0 || weekday > 6) {
2152 weekdayOverflow =
true;
2154 }
else if (w.e != null) {
2156 weekday = w.e + dow;
2157 if (w.e < 0 || w.e > 6) {
2158 weekdayOverflow =
true;
2165 if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
2166 getParsingFlags(config)._overflowWeeks =
true;
2167 }
else if (weekdayOverflow != null) {
2168 getParsingFlags(config)._overflowWeekday =
true;
2170 temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
2171 config._a[YEAR] = temp.year;
2172 config._dayOfYear = temp.dayOfYear;
2178 var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
2179 var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
2181 var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
2184 [
'YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
2185 [
'YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
2186 [
'GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
2187 [
'GGGG-[W]WW', /\d{4}-W\d\d/,
false],
2188 [
'YYYY-DDD', /\d{4}-\d{3}/],
2189 [
'YYYY-MM', /\d{4}-\d\d/,
false],
2190 [
'YYYYYYMMDD', /[+-]\d{10}/],
2191 [
'YYYYMMDD', /\d{8}/],
2193 [
'GGGG[W]WWE', /\d{4}W\d{3}/],
2194 [
'GGGG[W]WW', /\d{4}W\d{2}/,
false],
2195 [
'YYYYDDD', /\d{7}/]
2200 [
'HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
2201 [
'HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
2202 [
'HH:mm:ss', /\d\d:\d\d:\d\d/],
2203 [
'HH:mm', /\d\d:\d\d/],
2204 [
'HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
2205 [
'HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
2206 [
'HHmmss', /\d\d\d\d\d\d/],
2207 [
'HHmm', /\d\d\d\d/],
2211 var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
2214 function configFromISO(config) {
2217 match = extendedIsoRegex.exec(
string) || basicIsoRegex.exec(
string),
2218 allowTime, dateFormat, timeFormat, tzFormat;
2221 getParsingFlags(config).iso =
true;
2223 for (i = 0, l = isoDates.length; i < l; i++) {
2224 if (isoDates[i][1].exec(match[1])) {
2225 dateFormat = isoDates[i][0];
2226 allowTime = isoDates[i][2] !==
false;
2230 if (dateFormat == null) {
2231 config._isValid =
false;
2235 for (i = 0, l = isoTimes.length; i < l; i++) {
2236 if (isoTimes[i][1].exec(match[3])) {
2238 timeFormat = (match[2] ||
' ') + isoTimes[i][0];
2242 if (timeFormat == null) {
2243 config._isValid =
false;
2247 if (!allowTime && timeFormat != null) {
2248 config._isValid =
false;
2252 if (tzRegex.exec(match[4])) {
2255 config._isValid =
false;
2259 config._f = dateFormat + (timeFormat ||
'') + (tzFormat ||
'');
2260 configFromStringAndFormat(config);
2262 config._isValid =
false;
2267 var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
2269 function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
2271 untruncateYear(yearStr),
2272 defaultLocaleMonthsShort.indexOf(monthStr),
2273 parseInt(dayStr, 10),
2274 parseInt(hourStr, 10),
2275 parseInt(minuteStr, 10)
2279 result.push(parseInt(secondStr, 10));
2285 function untruncateYear(yearStr) {
2286 var year = parseInt(yearStr, 10);
2289 }
else if (year <= 999) {
2295 function preprocessRFC2822(s) {
2297 return s.replace(/\([^)]*\)|[\n\t]/g,
' ').replace(/(\s\s+)/g,
' ').replace(/^\s\s*/,
'').replace(/\s\s*$/,
'');
2300 function checkWeekday(weekdayStr, parsedInput, config) {
2303 var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
2304 weekdayActual =
new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
2305 if (weekdayProvided !== weekdayActual) {
2306 getParsingFlags(config).weekdayMismatch =
true;
2307 config._isValid =
false;
2327 function calculateOffset(obsOffset, militaryOffset, numOffset) {
2329 return obsOffsets[obsOffset];
2330 }
else if (militaryOffset) {
2334 var hm = parseInt(numOffset, 10);
2335 var m = hm % 100, h = (hm - m) / 100;
2341 function configFromRFC2822(config) {
2342 var match = rfc2822.exec(preprocessRFC2822(config._i));
2344 var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
2345 if (!checkWeekday(match[1], parsedArray, config)) {
2349 config._a = parsedArray;
2350 config._tzm = calculateOffset(match[8], match[9], match[10]);
2352 config._d = createUTCDate.apply(null, config._a);
2353 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
2355 getParsingFlags(config).rfc2822 =
true;
2357 config._isValid =
false;
2362 function configFromString(config) {
2363 var matched = aspNetJsonRegex.exec(config._i);
2365 if (matched !== null) {
2366 config._d =
new Date(+matched[1]);
2370 configFromISO(config);
2371 if (config._isValid ===
false) {
2372 delete config._isValid;
2377 configFromRFC2822(config);
2378 if (config._isValid ===
false) {
2379 delete config._isValid;
2385 hooks.createFromInputFallback(config);
2388 hooks.createFromInputFallback = deprecate(
2389 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
2390 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
2391 'discouraged and will be removed in an upcoming major release. Please refer to ' +
2392 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
2394 config._d =
new Date(config._i + (config._useUTC ?
' UTC' :
''));
2399 hooks.ISO_8601 =
function () {};
2402 hooks.RFC_2822 =
function () {};
2405 function configFromStringAndFormat(config) {
2407 if (config._f === hooks.ISO_8601) {
2408 configFromISO(config);
2411 if (config._f === hooks.RFC_2822) {
2412 configFromRFC2822(config);
2416 getParsingFlags(config).empty =
true;
2419 var
string =
'' + config._i,
2420 i, parsedInput, tokens, token, skipped,
2421 stringLength =
string.length,
2422 totalParsedInputLength = 0;
2424 tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
2426 for (i = 0; i < tokens.length; i++) {
2428 parsedInput = (
string.match(getParseRegexForToken(token, config)) || [])[0];
2432 skipped =
string.substr(0,
string.indexOf(parsedInput));
2433 if (skipped.length > 0) {
2434 getParsingFlags(config).unusedInput.push(skipped);
2436 string =
string.slice(
string.indexOf(parsedInput) + parsedInput.length);
2437 totalParsedInputLength += parsedInput.length;
2440 if (formatTokenFunctions[token]) {
2442 getParsingFlags(config).empty =
false;
2445 getParsingFlags(config).unusedTokens.push(token);
2447 addTimeToArrayFromToken(token, parsedInput, config);
2449 else if (config._strict && !parsedInput) {
2450 getParsingFlags(config).unusedTokens.push(token);
2455 getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
2456 if (
string.length > 0) {
2457 getParsingFlags(config).unusedInput.push(
string);
2461 if (config._a[HOUR] <= 12 &&
2462 getParsingFlags(config).bigHour ===
true &&
2463 config._a[HOUR] > 0) {
2464 getParsingFlags(config).bigHour = undefined;
2467 getParsingFlags(config).parsedDateParts = config._a.slice(0);
2468 getParsingFlags(config).meridiem = config._meridiem;
2470 config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
2472 configFromArray(config);
2473 checkOverflow(config);
2477 function meridiemFixWrap (locale, hour, meridiem) {
2480 if (meridiem == null) {
2484 if (locale.meridiemHour != null) {
2485 return locale.meridiemHour(hour, meridiem);
2486 }
else if (locale.isPM != null) {
2488 isPm = locale.isPM(meridiem);
2489 if (isPm && hour < 12) {
2492 if (!isPm && hour === 12) {
2503 function configFromStringAndArray(config) {
2511 if (config._f.length === 0) {
2512 getParsingFlags(config).invalidFormat =
true;
2513 config._d =
new Date(NaN);
2517 for (i = 0; i < config._f.length; i++) {
2519 tempConfig = copyConfig({}, config);
2520 if (config._useUTC != null) {
2521 tempConfig._useUTC = config._useUTC;
2523 tempConfig._f = config._f[i];
2524 configFromStringAndFormat(tempConfig);
2526 if (!isValid(tempConfig)) {
2531 currentScore += getParsingFlags(tempConfig).charsLeftOver;
2534 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
2536 getParsingFlags(tempConfig).score = currentScore;
2538 if (scoreToBeat == null || currentScore < scoreToBeat) {
2539 scoreToBeat = currentScore;
2540 bestMoment = tempConfig;
2544 extend(config, bestMoment || tempConfig);
2547 function configFromObject(config) {
2552 var i = normalizeObjectUnits(config._i);
2553 config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
2554 return obj && parseInt(obj, 10);
2557 configFromArray(config);
2560 function createFromConfig (config) {
2561 var res =
new Moment(checkOverflow(prepareConfig(config)));
2565 res._nextDay = undefined;
2571 function prepareConfig (config) {
2572 var input = config._i,
2575 config._locale = config._locale || getLocale(config._l);
2577 if (input === null || (format === undefined && input ===
'')) {
2578 return createInvalid({nullInput:
true});
2581 if (typeof input ===
'string') {
2582 config._i = input = config._locale.preparse(input);
2585 if (isMoment(input)) {
2586 return new Moment(checkOverflow(input));
2587 }
else if (isDate(input)) {
2589 }
else if (isArray(format)) {
2590 configFromStringAndArray(config);
2591 }
else if (format) {
2592 configFromStringAndFormat(config);
2594 configFromInput(config);
2597 if (!isValid(config)) {
2604 function configFromInput(config) {
2605 var input = config._i;
2606 if (isUndefined(input)) {
2607 config._d =
new Date(hooks.now());
2608 }
else if (isDate(input)) {
2609 config._d =
new Date(input.valueOf());
2610 }
else if (typeof input ===
'string') {
2611 configFromString(config);
2612 }
else if (isArray(input)) {
2613 config._a = map(input.slice(0),
function (obj) {
2614 return parseInt(obj, 10);
2616 configFromArray(config);
2617 }
else if (isObject(input)) {
2618 configFromObject(config);
2619 }
else if (isNumber(input)) {
2621 config._d =
new Date(input);
2623 hooks.createFromInputFallback(config);
2627 function createLocalOrUTC (input, format, locale, strict, isUTC) {
2630 if (locale ===
true || locale ===
false) {
2635 if ((isObject(input) && isObjectEmpty(input)) ||
2636 (isArray(input) && input.length === 0)) {
2641 c._isAMomentObject =
true;
2642 c._useUTC = c._isUTC = isUTC;
2648 return createFromConfig(c);
2651 function createLocal (input, format, locale, strict) {
2652 return createLocalOrUTC(input, format, locale, strict,
false);
2655 var prototypeMin = deprecate(
2656 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
2658 var other = createLocal.apply(null, arguments);
2659 if (this.isValid() && other.isValid()) {
2660 return other <
this ?
this : other;
2662 return createInvalid();
2667 var prototypeMax = deprecate(
2668 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
2670 var other = createLocal.apply(null, arguments);
2671 if (this.isValid() && other.isValid()) {
2672 return other >
this ?
this : other;
2674 return createInvalid();
2684 function pickBy(fn, moments) {
2686 if (moments.length === 1 && isArray(moments[0])) {
2687 moments = moments[0];
2689 if (!moments.length) {
2690 return createLocal();
2693 for (i = 1; i < moments.length; ++i) {
2694 if (!moments[i].isValid() || moments[i][fn](res)) {
2703 var args = [].slice.call(arguments, 0);
2705 return pickBy(
'isBefore', args);
2709 var args = [].slice.call(arguments, 0);
2711 return pickBy(
'isAfter', args);
2714 var now =
function () {
2715 return Date.now ? Date.now() : +(
new Date());
2718 var ordering = [
'year',
'quarter',
'month',
'week',
'day',
'hour',
'minute',
'second',
'millisecond'];
2720 function isDurationValid(m) {
2721 for (var key in m) {
2722 if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
2727 var unitHasDecimal =
false;
2728 for (var i = 0; i < ordering.length; ++i) {
2729 if (m[ordering[i]]) {
2730 if (unitHasDecimal) {
2733 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
2734 unitHasDecimal =
true;
2742 function isValid$1() {
2743 return this._isValid;
2746 function createInvalid$1() {
2747 return createDuration(NaN);
2750 function Duration (duration) {
2751 var normalizedInput = normalizeObjectUnits(duration),
2752 years = normalizedInput.year || 0,
2753 quarters = normalizedInput.quarter || 0,
2754 months = normalizedInput.month || 0,
2755 weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
2756 days = normalizedInput.day || 0,
2757 hours = normalizedInput.hour || 0,
2758 minutes = normalizedInput.minute || 0,
2759 seconds = normalizedInput.second || 0,
2760 milliseconds = normalizedInput.millisecond || 0;
2762 this._isValid = isDurationValid(normalizedInput);
2765 this._milliseconds = +milliseconds +
2768 hours * 1000 * 60 * 60;
2771 this._days = +days +
2776 this._months = +months +
2782 this._locale = getLocale();
2787 function isDuration (obj) {
2788 return obj instanceof Duration;
2791 function absRound (number) {
2793 return Math.round(-1 * number) * -1;
2795 return Math.round(number);
2801 function offset (token, separator) {
2802 addFormatToken(token, 0, 0,
function () {
2803 var offset = this.utcOffset();
2809 return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
2818 addRegexToken(
'Z', matchShortOffset);
2819 addRegexToken(
'ZZ', matchShortOffset);
2820 addParseToken([
'Z',
'ZZ'],
function (input, array, config) {
2821 config._useUTC =
true;
2822 config._tzm = offsetFromString(matchShortOffset, input);
2830 var chunkOffset = /([\+\-]|\d\d)/gi;
2832 function offsetFromString(matcher,
string) {
2833 var matches = (
string ||
'').match(matcher);
2835 if (matches === null) {
2839 var chunk = matches[matches.length - 1] || [];
2840 var parts = (chunk +
'').match(chunkOffset) || [
'-', 0, 0];
2841 var minutes = +(parts[1] * 60) + toInt(parts[2]);
2843 return minutes === 0 ?
2845 parts[0] ===
'+' ? minutes : -minutes;
2849 function cloneWithOffset(input, model) {
2852 res = model.clone();
2853 diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
2855 res._d.setTime(res._d.valueOf() + diff);
2856 hooks.updateOffset(res,
false);
2859 return createLocal(input).local();
2863 function getDateOffset (m) {
2866 return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
2873 hooks.updateOffset =
function () {};
2887 function getSetOffset (input, keepLocalTime, keepMinutes) {
2888 var offset = this._offset || 0,
2890 if (!this.isValid()) {
2891 return input != null ?
this : NaN;
2893 if (input != null) {
2894 if (typeof input ===
'string') {
2895 input = offsetFromString(matchShortOffset, input);
2896 if (input === null) {
2899 }
else if (Math.abs(input) < 16 && !keepMinutes) {
2902 if (!this._isUTC && keepLocalTime) {
2903 localAdjust = getDateOffset(
this);
2905 this._offset = input;
2907 if (localAdjust != null) {
2908 this.add(localAdjust,
'm');
2910 if (offset !== input) {
2911 if (!keepLocalTime || this._changeInProgress) {
2912 addSubtract(
this, createDuration(input - offset,
'm'), 1,
false);
2913 }
else if (!this._changeInProgress) {
2914 this._changeInProgress =
true;
2915 hooks.updateOffset(
this,
true);
2916 this._changeInProgress = null;
2921 return this._isUTC ? offset : getDateOffset(
this);
2925 function getSetZone (input, keepLocalTime) {
2926 if (input != null) {
2927 if (typeof input !==
'string') {
2931 this.utcOffset(input, keepLocalTime);
2935 return -this.utcOffset();
2939 function setOffsetToUTC (keepLocalTime) {
2940 return this.utcOffset(0, keepLocalTime);
2943 function setOffsetToLocal (keepLocalTime) {
2945 this.utcOffset(0, keepLocalTime);
2946 this._isUTC =
false;
2948 if (keepLocalTime) {
2949 this.subtract(getDateOffset(
this),
'm');
2955 function setOffsetToParsedOffset () {
2956 if (this._tzm != null) {
2957 this.utcOffset(this._tzm,
false,
true);
2958 }
else if (typeof this._i ===
'string') {
2959 var tZone = offsetFromString(matchOffset, this._i);
2960 if (tZone != null) {
2961 this.utcOffset(tZone);
2964 this.utcOffset(0,
true);
2970 function hasAlignedHourOffset (input) {
2971 if (!this.isValid()) {
2974 input = input ? createLocal(input).utcOffset() : 0;
2976 return (this.utcOffset() - input) % 60 === 0;
2979 function isDaylightSavingTime () {
2981 this.utcOffset() > this.clone().month(0).utcOffset() ||
2982 this.utcOffset() > this.clone().month(5).utcOffset()
2986 function isDaylightSavingTimeShifted () {
2987 if (!isUndefined(this._isDSTShifted)) {
2988 return this._isDSTShifted;
2993 copyConfig(c,
this);
2994 c = prepareConfig(c);
2997 var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
2998 this._isDSTShifted = this.isValid() &&
2999 compareArrays(c._a, other.toArray()) > 0;
3001 this._isDSTShifted =
false;
3004 return this._isDSTShifted;
3007 function isLocal () {
3008 return this.isValid() ? !this._isUTC :
false;
3011 function isUtcOffset () {
3012 return this.isValid() ? this._isUTC :
false;
3016 return this.isValid() ? this._isUTC && this._offset === 0 :
false;
3020 var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
3025 var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
3027 function createDuration (input, key) {
3028 var duration = input,
3035 if (isDuration(input)) {
3037 ms : input._milliseconds,
3041 }
else if (isNumber(input)) {
3044 duration[key] = input;
3046 duration.milliseconds = input;
3048 }
else if (!!(match = aspNetRegex.exec(input))) {
3049 sign = (match[1] ===
'-') ? -1 : 1;
3052 d : toInt(match[DATE]) * sign,
3053 h : toInt(match[HOUR]) * sign,
3054 m : toInt(match[MINUTE]) * sign,
3055 s : toInt(match[SECOND]) * sign,
3056 ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign
3058 }
else if (!!(match = isoRegex.exec(input))) {
3059 sign = (match[1] ===
'-') ? -1 : 1;
3061 y : parseIso(match[2], sign),
3062 M : parseIso(match[3], sign),
3063 w : parseIso(match[4], sign),
3064 d : parseIso(match[5], sign),
3065 h : parseIso(match[6], sign),
3066 m : parseIso(match[7], sign),
3067 s : parseIso(match[8], sign)
3069 }
else if (duration == null) {
3071 }
else if (typeof duration ===
'object' && (
'from' in duration ||
'to' in duration)) {
3072 diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
3075 duration.ms = diffRes.milliseconds;
3076 duration.M = diffRes.months;
3079 ret =
new Duration(duration);
3081 if (isDuration(input) && hasOwnProp(input,
'_locale')) {
3082 ret._locale = input._locale;
3088 createDuration.fn = Duration.prototype;
3089 createDuration.invalid = createInvalid$1;
3091 function parseIso (inp, sign) {
3095 var res = inp && parseFloat(inp.replace(
',',
'.'));
3097 return (isNaN(res) ? 0 : res) * sign;
3100 function positiveMomentsDifference(base, other) {
3103 res.months = other.month() - base.month() +
3104 (other.year() - base.year()) * 12;
3105 if (base.clone().add(res.months,
'M').isAfter(other)) {
3109 res.milliseconds = +other - +(base.clone().add(res.months,
'M'));
3114 function momentsDifference(base, other) {
3116 if (!(base.isValid() && other.isValid())) {
3117 return {milliseconds: 0, months: 0};
3120 other = cloneWithOffset(other, base);
3121 if (base.isBefore(other)) {
3122 res = positiveMomentsDifference(base, other);
3124 res = positiveMomentsDifference(other, base);
3125 res.milliseconds = -res.milliseconds;
3126 res.months = -res.months;
3133 function createAdder(direction, name) {
3134 return function (val, period) {
3137 if (period !== null && !isNaN(+period)) {
3138 deprecateSimple(name,
'moment().' + name +
'(period, number) is deprecated. Please use moment().' + name +
'(number, period). ' +
3139 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
3140 tmp = val; val = period; period = tmp;
3143 val = typeof val ===
'string' ? +val : val;
3144 dur = createDuration(val, period);
3145 addSubtract(
this, dur, direction);
3150 function addSubtract (mom, duration, isAdding, updateOffset) {
3151 var milliseconds = duration._milliseconds,
3152 days = absRound(duration._days),
3153 months = absRound(duration._months);
3155 if (!mom.isValid()) {
3160 updateOffset = updateOffset == null ?
true : updateOffset;
3163 setMonth(mom,
get(mom,
'Month') + months * isAdding);
3166 set$1(mom,
'Date',
get(mom,
'Date') + days * isAdding);
3169 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
3172 hooks.updateOffset(mom, days || months);
3176 var add = createAdder(1,
'add');
3177 var subtract = createAdder(-1,
'subtract');
3179 function getCalendarFormat(myMoment, now) {
3180 var diff = myMoment.diff(now,
'days',
true);
3181 return diff < -6 ?
'sameElse' :
3182 diff < -1 ?
'lastWeek' :
3183 diff < 0 ?
'lastDay' :
3184 diff < 1 ?
'sameDay' :
3185 diff < 2 ?
'nextDay' :
3186 diff < 7 ?
'nextWeek' :
'sameElse';
3189 function calendar$1 (time, formats) {
3192 var now = time || createLocal(),
3193 sod = cloneWithOffset(now,
this).startOf(
'day'),
3194 format = hooks.calendarFormat(
this, sod) ||
'sameElse';
3196 var output = formats && (isFunction(formats[format]) ? formats[format].call(
this, now) : formats[format]);
3198 return this.format(output || this.localeData().calendar(format,
this, createLocal(now)));
3202 return new Moment(
this);
3205 function isAfter (input, units) {
3206 var localInput = isMoment(input) ? input : createLocal(input);
3207 if (!(this.isValid() && localInput.isValid())) {
3210 units = normalizeUnits(units) ||
'millisecond';
3211 if (units ===
'millisecond') {
3212 return this.valueOf() > localInput.valueOf();
3214 return localInput.valueOf() < this.clone().startOf(units).valueOf();
3218 function isBefore (input, units) {
3219 var localInput = isMoment(input) ? input : createLocal(input);
3220 if (!(this.isValid() && localInput.isValid())) {
3223 units = normalizeUnits(units) ||
'millisecond';
3224 if (units ===
'millisecond') {
3225 return this.valueOf() < localInput.valueOf();
3227 return this.clone().endOf(units).valueOf() < localInput.valueOf();
3231 function isBetween (from, to, units, inclusivity) {
3232 var localFrom = isMoment(from) ? from : createLocal(from),
3233 localTo = isMoment(to) ? to : createLocal(to);
3234 if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
3237 inclusivity = inclusivity ||
'()';
3238 return (inclusivity[0] ===
'(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
3239 (inclusivity[1] ===
')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
3242 function isSame (input, units) {
3243 var localInput = isMoment(input) ? input : createLocal(input),
3245 if (!(this.isValid() && localInput.isValid())) {
3248 units = normalizeUnits(units) ||
'millisecond';
3249 if (units ===
'millisecond') {
3250 return this.valueOf() === localInput.valueOf();
3252 inputMs = localInput.valueOf();
3253 return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
3257 function isSameOrAfter (input, units) {
3258 return this.isSame(input, units) || this.isAfter(input, units);
3261 function isSameOrBefore (input, units) {
3262 return this.isSame(input, units) || this.isBefore(input, units);
3265 function diff (input, units, asFloat) {
3270 if (!this.isValid()) {
3274 that = cloneWithOffset(input,
this);
3276 if (!that.isValid()) {
3280 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
3282 units = normalizeUnits(units);
3285 case 'year': output = monthDiff(
this, that) / 12;
break;
3286 case 'month': output = monthDiff(
this, that);
break;
3287 case 'quarter': output = monthDiff(
this, that) / 3;
break;
3288 case 'second': output = (
this - that) / 1e3;
break;
3289 case 'minute': output = (
this - that) / 6e4;
break;
3290 case 'hour': output = (
this - that) / 36e5;
break;
3291 case 'day': output = (
this - that - zoneDelta) / 864e5;
break;
3292 case 'week': output = (
this - that - zoneDelta) / 6048e5;
break;
3293 default: output =
this - that;
3296 return asFloat ? output : absFloor(output);
3299 function monthDiff (a, b) {
3301 var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
3303 anchor = a.clone().add(wholeMonthDiff,
'months'),
3306 if (b - anchor < 0) {
3307 anchor2 = a.clone().add(wholeMonthDiff - 1,
'months');
3309 adjust = (b - anchor) / (anchor - anchor2);
3311 anchor2 = a.clone().add(wholeMonthDiff + 1,
'months');
3313 adjust = (b - anchor) / (anchor2 - anchor);
3317 return -(wholeMonthDiff + adjust) || 0;
3320 hooks.defaultFormat =
'YYYY-MM-DDTHH:mm:ssZ';
3321 hooks.defaultFormatUtc =
'YYYY-MM-DDTHH:mm:ss[Z]';
3323 function toString () {
3324 return this.clone().locale(
'en').format(
'ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
3327 function toISOString(keepOffset) {
3328 if (!this.isValid()) {
3331 var utc = keepOffset !==
true;
3332 var m = utc ? this.clone().utc() :
this;
3333 if (m.year() < 0 || m.year() > 9999) {
3334 return formatMoment(m, utc ?
'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' :
'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
3336 if (isFunction(Date.prototype.toISOString)) {
3339 return this.toDate().toISOString();
3341 return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace(
'Z', formatMoment(m,
'Z'));
3344 return formatMoment(m, utc ?
'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' :
'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
3353 function inspect () {
3354 if (!this.isValid()) {
3355 return 'moment.invalid(/* ' + this._i +
' */)';
3357 var func =
'moment';
3359 if (!this.isLocal()) {
3360 func = this.utcOffset() === 0 ?
'moment.utc' :
'moment.parseZone';
3363 var prefix =
'[' + func +
'("]';
3364 var year = (0 <= this.year() && this.year() <= 9999) ?
'YYYY' :
'YYYYYY';
3365 var datetime =
'-MM-DD[T]HH:mm:ss.SSS';
3366 var suffix = zone +
'[")]';
3368 return this.format(prefix + year + datetime + suffix);
3371 function format (inputString) {
3373 inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
3375 var output = formatMoment(
this, inputString);
3376 return this.localeData().postformat(output);
3379 function from (time, withoutSuffix) {
3380 if (this.isValid() &&
3381 ((isMoment(time) && time.isValid()) ||
3382 createLocal(time).isValid())) {
3383 return createDuration({to:
this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
3385 return this.localeData().invalidDate();
3389 function fromNow (withoutSuffix) {
3390 return this.from(createLocal(), withoutSuffix);
3393 function to (time, withoutSuffix) {
3394 if (this.isValid() &&
3395 ((isMoment(time) && time.isValid()) ||
3396 createLocal(time).isValid())) {
3397 return createDuration({from:
this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
3399 return this.localeData().invalidDate();
3403 function toNow (withoutSuffix) {
3404 return this.to(createLocal(), withoutSuffix);
3410 function locale (key) {
3413 if (key === undefined) {
3414 return this._locale._abbr;
3416 newLocaleData = getLocale(key);
3417 if (newLocaleData != null) {
3418 this._locale = newLocaleData;
3424 var lang = deprecate(
3425 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
3427 if (key === undefined) {
3428 return this.localeData();
3430 return this.locale(key);
3435 function localeData () {
3436 return this._locale;
3439 var MS_PER_SECOND = 1000;
3440 var MS_PER_MINUTE = 60 * MS_PER_SECOND;
3441 var MS_PER_HOUR = 60 * MS_PER_MINUTE;
3442 var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
3445 function mod$1(dividend, divisor) {
3446 return (dividend % divisor + divisor) % divisor;
3449 function localStartOfDate(y, m, d) {
3451 if (y < 100 && y >= 0) {
3453 return new Date(y + 400, m, d) - MS_PER_400_YEARS;
3455 return new Date(y, m, d).valueOf();
3459 function utcStartOfDate(y, m, d) {
3461 if (y < 100 && y >= 0) {
3463 return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
3465 return Date.UTC(y, m, d);
3469 function startOf (units) {
3471 units = normalizeUnits(units);
3472 if (units === undefined || units ===
'millisecond' || !this.isValid()) {
3476 var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
3480 time = startOfDate(this.year(), 0, 1);
3483 time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
3486 time = startOfDate(this.year(), this.month(), 1);
3489 time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
3492 time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
3496 time = startOfDate(this.year(), this.month(), this.date());
3499 time = this._d.valueOf();
3500 time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
3503 time = this._d.valueOf();
3504 time -= mod$1(time, MS_PER_MINUTE);
3507 time = this._d.valueOf();
3508 time -= mod$1(time, MS_PER_SECOND);
3512 this._d.setTime(time);
3513 hooks.updateOffset(
this,
true);
3517 function endOf (units) {
3519 units = normalizeUnits(units);
3520 if (units === undefined || units ===
'millisecond' || !this.isValid()) {
3524 var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
3528 time = startOfDate(this.year() + 1, 0, 1) - 1;
3531 time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
3534 time = startOfDate(this.year(), this.month() + 1, 1) - 1;
3537 time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
3540 time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
3544 time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
3547 time = this._d.valueOf();
3548 time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
3551 time = this._d.valueOf();
3552 time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
3555 time = this._d.valueOf();
3556 time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
3560 this._d.setTime(time);
3561 hooks.updateOffset(
this,
true);
3565 function valueOf () {
3566 return this._d.valueOf() - ((this._offset || 0) * 60000);
3570 return Math.floor(this.valueOf() / 1000);
3573 function toDate () {
3574 return new Date(this.valueOf());
3577 function toArray () {
3579 return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
3582 function toObject () {
3589 minutes: m.minutes(),
3590 seconds: m.seconds(),
3591 milliseconds: m.milliseconds()
3595 function toJSON () {
3597 return this.isValid() ? this.toISOString() : null;
3600 function isValid$2 () {
3601 return isValid(
this);
3604 function parsingFlags () {
3605 return extend({}, getParsingFlags(
this));
3608 function invalidAt () {
3609 return getParsingFlags(
this).overflow;
3612 function creationData() {
3616 locale: this._locale,
3618 strict: this._strict
3624 addFormatToken(0, [
'gg', 2], 0,
function () {
3625 return this.weekYear() % 100;
3628 addFormatToken(0, [
'GG', 2], 0,
function () {
3629 return this.isoWeekYear() % 100;
3632 function addWeekYearFormatToken (token, getter) {
3633 addFormatToken(0, [token, token.length], 0, getter);
3636 addWeekYearFormatToken(
'gggg',
'weekYear');
3637 addWeekYearFormatToken(
'ggggg',
'weekYear');
3638 addWeekYearFormatToken(
'GGGG',
'isoWeekYear');
3639 addWeekYearFormatToken(
'GGGGG',
'isoWeekYear');
3643 addUnitAlias(
'weekYear',
'gg');
3644 addUnitAlias(
'isoWeekYear',
'GG');
3648 addUnitPriority(
'weekYear', 1);
3649 addUnitPriority(
'isoWeekYear', 1);
3654 addRegexToken(
'G', matchSigned);
3655 addRegexToken(
'g', matchSigned);
3656 addRegexToken(
'GG', match1to2, match2);
3657 addRegexToken(
'gg', match1to2, match2);
3658 addRegexToken(
'GGGG', match1to4, match4);
3659 addRegexToken(
'gggg', match1to4, match4);
3660 addRegexToken(
'GGGGG', match1to6, match6);
3661 addRegexToken(
'ggggg', match1to6, match6);
3663 addWeekParseToken([
'gggg',
'ggggg',
'GGGG',
'GGGGG'],
function (input, week, config, token) {
3664 week[token.substr(0, 2)] = toInt(input);
3667 addWeekParseToken([
'gg',
'GG'],
function (input, week, config, token) {
3668 week[token] = hooks.parseTwoDigitYear(input);
3673 function getSetWeekYear (input) {
3674 return getSetWeekYearHelper.call(
this,
3678 this.localeData()._week.dow,
3679 this.localeData()._week.doy);
3682 function getSetISOWeekYear (input) {
3683 return getSetWeekYearHelper.call(
this,
3684 input, this.isoWeek(), this.isoWeekday(), 1, 4);
3687 function getISOWeeksInYear () {
3688 return weeksInYear(this.year(), 1, 4);
3691 function getWeeksInYear () {
3692 var weekInfo = this.localeData()._week;
3693 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
3696 function getSetWeekYearHelper(input, week, weekday, dow, doy) {
3698 if (input == null) {
3699 return weekOfYear(
this, dow, doy).year;
3701 weeksTarget = weeksInYear(input, dow, doy);
3702 if (week > weeksTarget) {
3705 return setWeekAll.call(
this, input, week, weekday, dow, doy);
3709 function setWeekAll(weekYear, week, weekday, dow, doy) {
3710 var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
3711 date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
3713 this.year(date.getUTCFullYear());
3714 this.month(date.getUTCMonth());
3715 this.date(date.getUTCDate());
3721 addFormatToken(
'Q', 0,
'Qo',
'quarter');
3725 addUnitAlias(
'quarter',
'Q');
3729 addUnitPriority(
'quarter', 7);
3733 addRegexToken(
'Q', match1);
3734 addParseToken(
'Q',
function (input, array) {
3735 array[MONTH] = (toInt(input) - 1) * 3;
3740 function getSetQuarter (input) {
3741 return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
3746 addFormatToken(
'D', [
'DD', 2],
'Do',
'date');
3750 addUnitAlias(
'date',
'D');
3753 addUnitPriority(
'date', 9);
3757 addRegexToken(
'D', match1to2);
3758 addRegexToken(
'DD', match1to2, match2);
3759 addRegexToken(
'Do',
function (isStrict, locale) {
3762 (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
3763 locale._dayOfMonthOrdinalParseLenient;
3766 addParseToken([
'D',
'DD'], DATE);
3767 addParseToken(
'Do',
function (input, array) {
3768 array[DATE] = toInt(input.match(match1to2)[0]);
3773 var getSetDayOfMonth = makeGetSet(
'Date',
true);
3777 addFormatToken(
'DDD', [
'DDDD', 3],
'DDDo',
'dayOfYear');
3781 addUnitAlias(
'dayOfYear',
'DDD');
3784 addUnitPriority(
'dayOfYear', 4);
3788 addRegexToken(
'DDD', match1to3);
3789 addRegexToken(
'DDDD', match3);
3790 addParseToken([
'DDD',
'DDDD'],
function (input, array, config) {
3791 config._dayOfYear = toInt(input);
3798 function getSetDayOfYear (input) {
3799 var dayOfYear = Math.round((this.clone().startOf(
'day') - this.clone().startOf(
'year')) / 864e5) + 1;
3800 return input == null ? dayOfYear : this.add((input - dayOfYear),
'd');
3805 addFormatToken(
'm', [
'mm', 2], 0,
'minute');
3809 addUnitAlias(
'minute',
'm');
3813 addUnitPriority(
'minute', 14);
3817 addRegexToken(
'm', match1to2);
3818 addRegexToken(
'mm', match1to2, match2);
3819 addParseToken([
'm',
'mm'], MINUTE);
3823 var getSetMinute = makeGetSet(
'Minutes',
false);
3827 addFormatToken(
's', [
'ss', 2], 0,
'second');
3831 addUnitAlias(
'second',
's');
3835 addUnitPriority(
'second', 15);
3839 addRegexToken(
's', match1to2);
3840 addRegexToken(
'ss', match1to2, match2);
3841 addParseToken([
's',
'ss'], SECOND);
3845 var getSetSecond = makeGetSet(
'Seconds',
false);
3849 addFormatToken(
'S', 0, 0,
function () {
3850 return ~~(this.millisecond() / 100);
3853 addFormatToken(0, [
'SS', 2], 0,
function () {
3854 return ~~(this.millisecond() / 10);
3857 addFormatToken(0, [
'SSS', 3], 0,
'millisecond');
3858 addFormatToken(0, [
'SSSS', 4], 0,
function () {
3859 return this.millisecond() * 10;
3861 addFormatToken(0, [
'SSSSS', 5], 0,
function () {
3862 return this.millisecond() * 100;
3864 addFormatToken(0, [
'SSSSSS', 6], 0,
function () {
3865 return this.millisecond() * 1000;
3867 addFormatToken(0, [
'SSSSSSS', 7], 0,
function () {
3868 return this.millisecond() * 10000;
3870 addFormatToken(0, [
'SSSSSSSS', 8], 0,
function () {
3871 return this.millisecond() * 100000;
3873 addFormatToken(0, [
'SSSSSSSSS', 9], 0,
function () {
3874 return this.millisecond() * 1000000;
3880 addUnitAlias(
'millisecond',
'ms');
3884 addUnitPriority(
'millisecond', 16);
3888 addRegexToken(
'S', match1to3, match1);
3889 addRegexToken(
'SS', match1to3, match2);
3890 addRegexToken(
'SSS', match1to3, match3);
3893 for (token =
'SSSS'; token.length <= 9; token +=
'S') {
3894 addRegexToken(token, matchUnsigned);
3897 function parseMs(input, array) {
3898 array[MILLISECOND] = toInt((
'0.' + input) * 1000);
3901 for (token =
'S'; token.length <= 9; token +=
'S') {
3902 addParseToken(token, parseMs);
3906 var getSetMillisecond = makeGetSet(
'Milliseconds',
false);
3910 addFormatToken(
'z', 0, 0,
'zoneAbbr');
3911 addFormatToken(
'zz', 0, 0,
'zoneName');
3915 function getZoneAbbr () {
3916 return this._isUTC ?
'UTC' :
'';
3919 function getZoneName () {
3920 return this._isUTC ?
'Coordinated Universal Time' :
'';
3923 var proto = Moment.prototype;
3926 proto.calendar = calendar$1;
3927 proto.clone = clone;
3929 proto.endOf = endOf;
3930 proto.format = format;
3932 proto.fromNow = fromNow;
3934 proto.toNow = toNow;
3935 proto.get = stringGet;
3936 proto.invalidAt = invalidAt;
3937 proto.isAfter = isAfter;
3938 proto.isBefore = isBefore;
3939 proto.isBetween = isBetween;
3940 proto.isSame = isSame;
3941 proto.isSameOrAfter = isSameOrAfter;
3942 proto.isSameOrBefore = isSameOrBefore;
3943 proto.isValid = isValid$2;
3945 proto.locale = locale;
3946 proto.localeData = localeData;
3947 proto.max = prototypeMax;
3948 proto.min = prototypeMin;
3949 proto.parsingFlags = parsingFlags;
3950 proto.set = stringSet;
3951 proto.startOf = startOf;
3952 proto.subtract = subtract;
3953 proto.toArray = toArray;
3954 proto.toObject = toObject;
3955 proto.toDate = toDate;
3956 proto.toISOString = toISOString;
3957 proto.inspect = inspect;
3958 proto.toJSON = toJSON;
3959 proto.toString = toString;
3961 proto.valueOf = valueOf;
3962 proto.creationData = creationData;
3963 proto.year = getSetYear;
3964 proto.isLeapYear = getIsLeapYear;
3965 proto.weekYear = getSetWeekYear;
3966 proto.isoWeekYear = getSetISOWeekYear;
3967 proto.quarter = proto.quarters = getSetQuarter;
3968 proto.month = getSetMonth;
3969 proto.daysInMonth = getDaysInMonth;
3970 proto.week = proto.weeks = getSetWeek;
3971 proto.isoWeek = proto.isoWeeks = getSetISOWeek;
3972 proto.weeksInYear = getWeeksInYear;
3973 proto.isoWeeksInYear = getISOWeeksInYear;
3974 proto.date = getSetDayOfMonth;
3975 proto.day = proto.days = getSetDayOfWeek;
3976 proto.weekday = getSetLocaleDayOfWeek;
3977 proto.isoWeekday = getSetISODayOfWeek;
3978 proto.dayOfYear = getSetDayOfYear;
3979 proto.hour = proto.hours = getSetHour;
3980 proto.minute = proto.minutes = getSetMinute;
3981 proto.second = proto.seconds = getSetSecond;
3982 proto.millisecond = proto.milliseconds = getSetMillisecond;
3983 proto.utcOffset = getSetOffset;
3984 proto.utc = setOffsetToUTC;
3985 proto.local = setOffsetToLocal;
3986 proto.parseZone = setOffsetToParsedOffset;
3987 proto.hasAlignedHourOffset = hasAlignedHourOffset;
3988 proto.isDST = isDaylightSavingTime;
3989 proto.isLocal = isLocal;
3990 proto.isUtcOffset = isUtcOffset;
3991 proto.isUtc = isUtc;
3992 proto.isUTC = isUtc;
3993 proto.zoneAbbr = getZoneAbbr;
3994 proto.zoneName = getZoneName;
3995 proto.dates = deprecate(
'dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
3996 proto.months = deprecate(
'months accessor is deprecated. Use month instead', getSetMonth);
3997 proto.years = deprecate(
'years accessor is deprecated. Use year instead', getSetYear);
3998 proto.zone = deprecate(
'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
3999 proto.isDSTShifted = deprecate(
'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
4001 function createUnix (input) {
4002 return createLocal(input * 1000);
4005 function createInZone () {
4006 return createLocal.apply(null, arguments).parseZone();
4009 function preParsePostFormat (
string) {
4013 var proto$1 = Locale.prototype;
4015 proto$1.calendar = calendar;
4016 proto$1.longDateFormat = longDateFormat;
4017 proto$1.invalidDate = invalidDate;
4018 proto$1.ordinal = ordinal;
4019 proto$1.preparse = preParsePostFormat;
4020 proto$1.postformat = preParsePostFormat;
4021 proto$1.relativeTime = relativeTime;
4022 proto$1.pastFuture = pastFuture;
4025 proto$1.months = localeMonths;
4026 proto$1.monthsShort = localeMonthsShort;
4027 proto$1.monthsParse = localeMonthsParse;
4028 proto$1.monthsRegex = monthsRegex;
4029 proto$1.monthsShortRegex = monthsShortRegex;
4030 proto$1.week = localeWeek;
4031 proto$1.firstDayOfYear = localeFirstDayOfYear;
4032 proto$1.firstDayOfWeek = localeFirstDayOfWeek;
4034 proto$1.weekdays = localeWeekdays;
4035 proto$1.weekdaysMin = localeWeekdaysMin;
4036 proto$1.weekdaysShort = localeWeekdaysShort;
4037 proto$1.weekdaysParse = localeWeekdaysParse;
4039 proto$1.weekdaysRegex = weekdaysRegex;
4040 proto$1.weekdaysShortRegex = weekdaysShortRegex;
4041 proto$1.weekdaysMinRegex = weekdaysMinRegex;
4043 proto$1.isPM = localeIsPM;
4044 proto$1.meridiem = localeMeridiem;
4046 function get$1 (format, index, field, setter) {
4047 var locale = getLocale();
4048 var utc = createUTC().set(setter, index);
4049 return locale[field](utc, format);
4052 function listMonthsImpl (format, index, field) {
4053 if (isNumber(format)) {
4058 format = format ||
'';
4060 if (index != null) {
4061 return get$1(format, index, field,
'month');
4066 for (i = 0; i < 12; i++) {
4067 out[i] =
get$1(format, i, field,
'month');
4080 function listWeekdaysImpl (localeSorted, format, index, field) {
4081 if (typeof localeSorted ===
'boolean') {
4082 if (isNumber(format)) {
4087 format = format ||
'';
4089 format = localeSorted;
4091 localeSorted =
false;
4093 if (isNumber(format)) {
4098 format = format ||
'';
4101 var locale = getLocale(),
4102 shift = localeSorted ? locale._week.dow : 0;
4104 if (index != null) {
4105 return get$1(format, (index + shift) % 7, field,
'day');
4110 for (i = 0; i < 7; i++) {
4111 out[i] =
get$1(format, (i + shift) % 7, field,
'day');
4116 function listMonths (format, index) {
4117 return listMonthsImpl(format, index,
'months');
4120 function listMonthsShort (format, index) {
4121 return listMonthsImpl(format, index,
'monthsShort');
4124 function listWeekdays (localeSorted, format, index) {
4125 return listWeekdaysImpl(localeSorted, format, index,
'weekdays');
4128 function listWeekdaysShort (localeSorted, format, index) {
4129 return listWeekdaysImpl(localeSorted, format, index,
'weekdaysShort');
4132 function listWeekdaysMin (localeSorted, format, index) {
4133 return listWeekdaysImpl(localeSorted, format, index,
'weekdaysMin');
4136 getSetGlobalLocale(
'en', {
4137 dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
4138 ordinal :
function (number) {
4139 var b = number % 10,
4140 output = (toInt(number % 100 / 10) === 1) ?
'th' :
4143 (b === 3) ?
'rd' :
'th';
4144 return number + output;
4150 hooks.lang = deprecate(
'moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
4151 hooks.langData = deprecate(
'moment.langData is deprecated. Use moment.localeData instead.', getLocale);
4153 var mathAbs = Math.abs;
4156 var data = this._data;
4158 this._milliseconds = mathAbs(this._milliseconds);
4159 this._days = mathAbs(this._days);
4160 this._months = mathAbs(this._months);
4162 data.milliseconds = mathAbs(data.milliseconds);
4163 data.seconds = mathAbs(data.seconds);
4164 data.minutes = mathAbs(data.minutes);
4165 data.hours = mathAbs(data.hours);
4166 data.months = mathAbs(data.months);
4167 data.years = mathAbs(data.years);
4172 function addSubtract$1 (duration, input, value, direction) {
4173 var other = createDuration(input, value);
4175 duration._milliseconds += direction * other._milliseconds;
4176 duration._days += direction * other._days;
4177 duration._months += direction * other._months;
4179 return duration._bubble();
4183 function add$1 (input, value) {
4184 return addSubtract$1(
this, input, value, 1);
4188 function subtract$1 (input, value) {
4189 return addSubtract$1(
this, input, value, -1);
4192 function absCeil (number) {
4194 return Math.floor(number);
4196 return Math.ceil(number);
4200 function bubble () {
4201 var milliseconds = this._milliseconds;
4202 var days = this._days;
4203 var months = this._months;
4204 var data = this._data;
4205 var seconds, minutes, hours, years, monthsFromDays;
4209 if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
4210 (milliseconds <= 0 && days <= 0 && months <= 0))) {
4211 milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
4218 data.milliseconds = milliseconds % 1000;
4220 seconds = absFloor(milliseconds / 1000);
4221 data.seconds = seconds % 60;
4223 minutes = absFloor(seconds / 60);
4224 data.minutes = minutes % 60;
4226 hours = absFloor(minutes / 60);
4227 data.hours = hours % 24;
4229 days += absFloor(hours / 24);
4232 monthsFromDays = absFloor(daysToMonths(days));
4233 months += monthsFromDays;
4234 days -= absCeil(monthsToDays(monthsFromDays));
4237 years = absFloor(months / 12);
4241 data.months = months;
4247 function daysToMonths (days) {
4250 return days * 4800 / 146097;
4253 function monthsToDays (months) {
4255 return months * 146097 / 4800;
4258 function as (units) {
4259 if (!this.isValid()) {
4264 var milliseconds = this._milliseconds;
4266 units = normalizeUnits(units);
4268 if (units ===
'month' || units ===
'quarter' || units ===
'year') {
4269 days = this._days + milliseconds / 864e5;
4270 months = this._months + daysToMonths(days);
4272 case 'month':
return months;
4273 case 'quarter':
return months / 3;
4274 case 'year':
return months / 12;
4278 days = this._days + Math.round(monthsToDays(this._months));
4280 case 'week' :
return days / 7 + milliseconds / 6048e5;
4281 case 'day' :
return days + milliseconds / 864e5;
4282 case 'hour' :
return days * 24 + milliseconds / 36e5;
4283 case 'minute' :
return days * 1440 + milliseconds / 6e4;
4284 case 'second' :
return days * 86400 + milliseconds / 1000;
4286 case 'millisecond':
return Math.floor(days * 864e5) + milliseconds;
4287 default:
throw new Error(
'Unknown unit ' + units);
4293 function valueOf$1 () {
4294 if (!this.isValid()) {
4298 this._milliseconds +
4299 this._days * 864e5 +
4300 (this._months % 12) * 2592e6 +
4301 toInt(this._months / 12) * 31536e6
4305 function makeAs (alias) {
4306 return function () {
4307 return this.as(alias);
4311 var asMilliseconds = makeAs(
'ms');
4312 var asSeconds = makeAs(
's');
4313 var asMinutes = makeAs(
'm');
4314 var asHours = makeAs(
'h');
4315 var asDays = makeAs(
'd');
4316 var asWeeks = makeAs(
'w');
4317 var asMonths = makeAs(
'M');
4318 var asQuarters = makeAs(
'Q');
4319 var asYears = makeAs(
'y');
4321 function clone$1 () {
4322 return createDuration(
this);
4325 function get$2 (units) {
4326 units = normalizeUnits(units);
4327 return this.isValid() ?
this[units +
's']() : NaN;
4330 function makeGetter(name) {
4331 return function () {
4332 return this.isValid() ? this._data[name] : NaN;
4336 var milliseconds = makeGetter(
'milliseconds');
4337 var seconds = makeGetter(
'seconds');
4338 var minutes = makeGetter(
'minutes');
4339 var hours = makeGetter(
'hours');
4340 var days = makeGetter(
'days');
4341 var months = makeGetter(
'months');
4342 var years = makeGetter(
'years');
4345 return absFloor(this.days() / 7);
4348 var round = Math.round;
4359 function substituteTimeAgo(
string, number, withoutSuffix, isFuture, locale) {
4360 return locale.relativeTime(number || 1, !!withoutSuffix,
string, isFuture);
4363 function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
4364 var duration = createDuration(posNegDuration).abs();
4365 var seconds = round(duration.as(
's'));
4366 var minutes = round(duration.as(
'm'));
4367 var hours = round(duration.as(
'h'));
4368 var days = round(duration.as(
'd'));
4369 var months = round(duration.as(
'M'));
4370 var years = round(duration.as(
'y'));
4372 var a = seconds <= thresholds.ss && [
's', seconds] ||
4373 seconds < thresholds.s && [
'ss', seconds] ||
4374 minutes <= 1 && [
'm'] ||
4375 minutes < thresholds.m && [
'mm', minutes] ||
4376 hours <= 1 && [
'h'] ||
4377 hours < thresholds.h && [
'hh', hours] ||
4378 days <= 1 && [
'd'] ||
4379 days < thresholds.d && [
'dd', days] ||
4380 months <= 1 && [
'M'] ||
4381 months < thresholds.M && [
'MM', months] ||
4382 years <= 1 && [
'y'] || [
'yy', years];
4384 a[2] = withoutSuffix;
4385 a[3] = +posNegDuration > 0;
4387 return substituteTimeAgo.apply(null, a);
4391 function getSetRelativeTimeRounding (roundingFunction) {
4392 if (roundingFunction === undefined) {
4395 if (typeof(roundingFunction) ===
'function') {
4396 round = roundingFunction;
4403 function getSetRelativeTimeThreshold (threshold, limit) {
4404 if (thresholds[threshold] === undefined) {
4407 if (limit === undefined) {
4408 return thresholds[threshold];
4410 thresholds[threshold] = limit;
4411 if (threshold ===
's') {
4412 thresholds.ss = limit - 1;
4417 function humanize (withSuffix) {
4418 if (!this.isValid()) {
4419 return this.localeData().invalidDate();
4422 var locale = this.localeData();
4423 var output = relativeTime$1(
this, !withSuffix, locale);
4426 output = locale.pastFuture(+
this, output);
4429 return locale.postformat(output);
4432 var abs$1 = Math.abs;
4435 return ((x > 0) - (x < 0)) || +x;
4438 function toISOString$1() {
4446 if (!this.isValid()) {
4447 return this.localeData().invalidDate();
4450 var seconds = abs$1(this._milliseconds) / 1000;
4451 var days = abs$1(this._days);
4452 var months = abs$1(this._months);
4453 var minutes, hours, years;
4456 minutes = absFloor(seconds / 60);
4457 hours = absFloor(minutes / 60);
4462 years = absFloor(months / 12);
4472 var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/,
'') :
'';
4473 var total = this.asSeconds();
4481 var totalSign = total < 0 ?
'-' :
'';
4482 var ymSign = sign(this._months) !== sign(total) ?
'-' :
'';
4483 var daysSign = sign(this._days) !== sign(total) ?
'-' :
'';
4484 var hmsSign = sign(this._milliseconds) !== sign(total) ?
'-' :
'';
4486 return totalSign +
'P' +
4487 (Y ? ymSign + Y +
'Y' :
'') +
4488 (M ? ymSign + M +
'M' :
'') +
4489 (D ? daysSign + D +
'D' :
'') +
4490 ((h || m || s) ?
'T' :
'') +
4491 (h ? hmsSign + h +
'H' :
'') +
4492 (m ? hmsSign + m +
'M' :
'') +
4493 (s ? hmsSign + s +
'S' :
'');
4496 var proto$2 = Duration.prototype;
4498 proto$2.isValid = isValid$1;
4500 proto$2.add = add$1;
4501 proto$2.subtract = subtract$1;
4503 proto$2.asMilliseconds = asMilliseconds;
4504 proto$2.asSeconds = asSeconds;
4505 proto$2.asMinutes = asMinutes;
4506 proto$2.asHours = asHours;
4507 proto$2.asDays = asDays;
4508 proto$2.asWeeks = asWeeks;
4509 proto$2.asMonths = asMonths;
4510 proto$2.asQuarters = asQuarters;
4511 proto$2.asYears = asYears;
4512 proto$2.valueOf = valueOf$1;
4513 proto$2._bubble = bubble;
4514 proto$2.clone = clone$1;
4515 proto$2.get =
get$2;
4516 proto$2.milliseconds = milliseconds;
4517 proto$2.seconds = seconds;
4518 proto$2.minutes = minutes;
4519 proto$2.hours = hours;
4520 proto$2.days = days;
4521 proto$2.weeks = weeks;
4522 proto$2.months = months;
4523 proto$2.years = years;
4524 proto$2.humanize = humanize;
4525 proto$2.toISOString = toISOString$1;
4526 proto$2.toString = toISOString$1;
4527 proto$2.toJSON = toISOString$1;
4528 proto$2.locale = locale;
4529 proto$2.localeData = localeData;
4531 proto$2.toIsoString = deprecate(
'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
4532 proto$2.lang = lang;
4538 addFormatToken(
'X', 0, 0,
'unix');
4539 addFormatToken(
'x', 0, 0,
'valueOf');
4543 addRegexToken(
'x', matchSigned);
4544 addRegexToken(
'X', matchTimestamp);
4545 addParseToken(
'X',
function (input, array, config) {
4546 config._d =
new Date(parseFloat(input, 10) * 1000);
4548 addParseToken(
'x',
function (input, array, config) {
4549 config._d =
new Date(toInt(input));
4555 hooks.version =
'2.24.0';
4557 setHookCallback(createLocal);
4563 hooks.utc = createUTC;
4564 hooks.unix = createUnix;
4565 hooks.months = listMonths;
4566 hooks.isDate = isDate;
4567 hooks.locale = getSetGlobalLocale;
4568 hooks.invalid = createInvalid;
4569 hooks.duration = createDuration;
4570 hooks.isMoment = isMoment;
4571 hooks.weekdays = listWeekdays;
4572 hooks.parseZone = createInZone;
4573 hooks.localeData = getLocale;
4574 hooks.isDuration = isDuration;
4575 hooks.monthsShort = listMonthsShort;
4576 hooks.weekdaysMin = listWeekdaysMin;
4577 hooks.defineLocale = defineLocale;
4578 hooks.updateLocale = updateLocale;
4579 hooks.locales = listLocales;
4580 hooks.weekdaysShort = listWeekdaysShort;
4581 hooks.normalizeUnits = normalizeUnits;
4582 hooks.relativeTimeRounding = getSetRelativeTimeRounding;
4583 hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
4584 hooks.calendarFormat = getCalendarFormat;
4585 hooks.prototype = proto;
4589 DATETIME_LOCAL:
'YYYY-MM-DDTHH:mm',
4590 DATETIME_LOCAL_SECONDS:
'YYYY-MM-DDTHH:mm:ss',
4591 DATETIME_LOCAL_MS:
'YYYY-MM-DDTHH:mm:ss.SSS',
4594 TIME_SECONDS:
'HH:mm:ss',
4595 TIME_MS:
'HH:mm:ss.SSS',