3 //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
10 return hookCallback
.apply(null, arguments
);
13 // This is done to register the method called with moment()
14 // without creating circular dependencies.
15 function setHookCallback(callback
) {
16 hookCallback
= callback
;
19 function isArray(input
) {
21 input
instanceof Array
||
22 Object
.prototype.toString
.call(input
) === '[object Array]'
26 function isObject(input
) {
27 // IE8 will treat undefined and null as object if it wasn't for
31 Object
.prototype.toString
.call(input
) === '[object Object]'
35 function hasOwnProp(a
, b
) {
36 return Object
.prototype.hasOwnProperty
.call(a
, b
);
39 function isObjectEmpty(obj
) {
40 if (Object
.getOwnPropertyNames
) {
41 return Object
.getOwnPropertyNames(obj
).length
=== 0;
45 if (hasOwnProp(obj
, k
)) {
53 function isUndefined(input
) {
54 return input
=== void 0;
57 function isNumber(input
) {
59 typeof input
=== 'number' ||
60 Object
.prototype.toString
.call(input
) === '[object Number]'
64 function isDate(input
) {
66 input
instanceof Date
||
67 Object
.prototype.toString
.call(input
) === '[object Date]'
71 function map(arr
, fn
) {
74 for (i
= 0; i
< arr
.length
; ++i
) {
75 res
.push(fn(arr
[i
], i
));
80 function extend(a
, b
) {
82 if (hasOwnProp(b
, i
)) {
87 if (hasOwnProp(b
, 'toString')) {
88 a
.toString
= b
.toString
;
91 if (hasOwnProp(b
, 'valueOf')) {
92 a
.valueOf
= b
.valueOf
;
98 function createUTC(input
, format
, locale
, strict
) {
99 return createLocalOrUTC(input
, format
, locale
, strict
, true).utc();
102 function defaultParsingFlags() {
103 // We need to deep clone this object.
113 invalidFormat
: false,
114 userInvalidated
: false,
120 weekdayMismatch
: false,
124 function getParsingFlags(m
) {
126 m
._pf
= defaultParsingFlags();
132 if (Array
.prototype.some
) {
133 some
= Array
.prototype.some
;
135 some = function (fun
) {
136 var t
= Object(this),
137 len
= t
.length
>>> 0,
140 for (i
= 0; i
< len
; i
++) {
141 if (i
in t
&& fun
.call(this, t
[i
], i
, t
)) {
150 function isValid(m
) {
151 if (m
._isValid
== null) {
152 var flags
= getParsingFlags(m
),
153 parsedParts
= some
.call(flags
.parsedDateParts
, function (i
) {
157 !isNaN(m
._d
.getTime()) &&
158 flags
.overflow
< 0 &&
161 !flags
.invalidMonth
&&
162 !flags
.invalidWeekday
&&
163 !flags
.weekdayMismatch
&&
165 !flags
.invalidFormat
&&
166 !flags
.userInvalidated
&&
167 (!flags
.meridiem
|| (flags
.meridiem
&& parsedParts
));
172 flags
.charsLeftOver
=== 0 &&
173 flags
.unusedTokens
.length
=== 0 &&
174 flags
.bigHour
=== undefined;
177 if (Object
.isFrozen
== null || !Object
.isFrozen(m
)) {
178 m
._isValid
= isNowValid
;
186 function createInvalid(flags
) {
187 var m
= createUTC(NaN
);
189 extend(getParsingFlags(m
), flags
);
191 getParsingFlags(m
).userInvalidated
= true;
197 // Plugins that add properties should also add the key here (null value),
198 // so we can properly clone ourselves.
199 var momentProperties
= (hooks
.momentProperties
= []),
200 updateInProgress
= false;
202 function copyConfig(to
, from) {
205 if (!isUndefined(from._isAMomentObject
)) {
206 to
._isAMomentObject
= from._isAMomentObject
;
208 if (!isUndefined(from._i
)) {
211 if (!isUndefined(from._f
)) {
214 if (!isUndefined(from._l
)) {
217 if (!isUndefined(from._strict
)) {
218 to
._strict
= from._strict
;
220 if (!isUndefined(from._tzm
)) {
223 if (!isUndefined(from._isUTC
)) {
224 to
._isUTC
= from._isUTC
;
226 if (!isUndefined(from._offset
)) {
227 to
._offset
= from._offset
;
229 if (!isUndefined(from._pf
)) {
230 to
._pf
= getParsingFlags(from);
232 if (!isUndefined(from._locale
)) {
233 to
._locale
= from._locale
;
236 if (momentProperties
.length
> 0) {
237 for (i
= 0; i
< momentProperties
.length
; i
++) {
238 prop
= momentProperties
[i
];
240 if (!isUndefined(val
)) {
249 // Moment prototype object
250 function Moment(config
) {
251 copyConfig(this, config
);
252 this._d
= new Date(config
._d
!= null ? config
._d
.getTime() : NaN
);
253 if (!this.isValid()) {
254 this._d
= new Date(NaN
);
256 // Prevent infinite loop in case updateOffset creates new moment
258 if (updateInProgress
=== false) {
259 updateInProgress
= true;
260 hooks
.updateOffset(this);
261 updateInProgress
= false;
265 function isMoment(obj
) {
267 obj
instanceof Moment
|| (obj
!= null && obj
._isAMomentObject
!= null)
273 hooks
.suppressDeprecationWarnings
=== false &&
274 typeof console
!== 'undefined' &&
277 console
.warn('Deprecation warning: ' + msg
);
281 function deprecate(msg
, fn
) {
282 var firstTime
= true;
284 return extend(function () {
285 if (hooks
.deprecationHandler
!= null) {
286 hooks
.deprecationHandler(null, msg
);
293 for (i
= 0; i
< arguments
.length
; i
++) {
295 if (typeof arguments
[i
] === 'object') {
296 arg
+= '\n[' + i
+ '] ';
297 for (key
in arguments
[0]) {
298 if (hasOwnProp(arguments
[0], key
)) {
299 arg
+= key
+ ': ' + arguments
[0][key
] + ', ';
302 arg
= arg
.slice(0, -2); // Remove trailing comma and space
311 Array
.prototype.slice
.call(args
).join('') +
317 return fn
.apply(this, arguments
);
321 var deprecations
= {};
323 function deprecateSimple(name
, msg
) {
324 if (hooks
.deprecationHandler
!= null) {
325 hooks
.deprecationHandler(name
, msg
);
327 if (!deprecations
[name
]) {
329 deprecations
[name
] = true;
333 hooks
.suppressDeprecationWarnings
= false;
334 hooks
.deprecationHandler
= null;
336 function isFunction(input
) {
338 (typeof Function
!== 'undefined' && input
instanceof Function
) ||
339 Object
.prototype.toString
.call(input
) === '[object Function]'
343 function set(config
) {
346 if (hasOwnProp(config
, i
)) {
348 if (isFunction(prop
)) {
351 this['_' + i
] = prop
;
355 this._config
= config
;
356 // Lenient ordinal parsing accepts just a number in addition to
357 // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
358 // TODO: Remove "ordinalParse" fallback in next major release.
359 this._dayOfMonthOrdinalParseLenient
= new RegExp(
360 (this._dayOfMonthOrdinalParse
.source
|| this._ordinalParse
.source
) +
366 function mergeConfigs(parentConfig
, childConfig
) {
367 var res
= extend({}, parentConfig
),
369 for (prop
in childConfig
) {
370 if (hasOwnProp(childConfig
, prop
)) {
371 if (isObject(parentConfig
[prop
]) && isObject(childConfig
[prop
])) {
373 extend(res
[prop
], parentConfig
[prop
]);
374 extend(res
[prop
], childConfig
[prop
]);
375 } else if (childConfig
[prop
] != null) {
376 res
[prop
] = childConfig
[prop
];
382 for (prop
in parentConfig
) {
384 hasOwnProp(parentConfig
, prop
) &&
385 !hasOwnProp(childConfig
, prop
) &&
386 isObject(parentConfig
[prop
])
388 // make sure changes to properties don't modify parent config
389 res
[prop
] = extend({}, res
[prop
]);
395 function Locale(config
) {
396 if (config
!= null) {
406 keys = function (obj
) {
410 if (hasOwnProp(obj
, i
)) {
418 var defaultCalendar
= {
419 sameDay
: '[Today at] LT',
420 nextDay
: '[Tomorrow at] LT',
421 nextWeek
: 'dddd [at] LT',
422 lastDay
: '[Yesterday at] LT',
423 lastWeek
: '[Last] dddd [at] LT',
427 function calendar(key
, mom
, now
) {
428 var output
= this._calendar
[key
] || this._calendar
['sameElse'];
429 return isFunction(output
) ? output
.call(mom
, now
) : output
;
432 function zeroFill(number
, targetLength
, forceSign
) {
433 var absNumber
= '' + Math
.abs(number
),
434 zerosToFill
= targetLength
- absNumber
.length
,
437 (sign
? (forceSign
? '+' : '') : '-') +
438 Math
.pow(10, Math
.max(0, zerosToFill
)).toString().substr(1) +
443 var formattingTokens
= /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
444 localFormattingTokens
= /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
445 formatFunctions
= {},
446 formatTokenFunctions
= {};
451 // callback: function () { this.month() + 1 }
452 function addFormatToken(token
, padded
, ordinal
, callback
) {
454 if (typeof callback
=== 'string') {
456 return this[callback
]();
460 formatTokenFunctions
[token
] = func
;
463 formatTokenFunctions
[padded
[0]] = function () {
464 return zeroFill(func
.apply(this, arguments
), padded
[1], padded
[2]);
468 formatTokenFunctions
[ordinal
] = function () {
469 return this.localeData().ordinal(
470 func
.apply(this, arguments
),
477 function removeFormattingTokens(input
) {
478 if (input
.match(/\[[\s\S]/)) {
479 return input
.replace(/^\[|\]$/g, '');
481 return input
.replace(/\\/g
, '');
484 function makeFormatFunction(format
) {
485 var array
= format
.match(formattingTokens
),
489 for (i
= 0, length
= array
.length
; i
< length
; i
++) {
490 if (formatTokenFunctions
[array
[i
]]) {
491 array
[i
] = formatTokenFunctions
[array
[i
]];
493 array
[i
] = removeFormattingTokens(array
[i
]);
497 return function (mom
) {
500 for (i
= 0; i
< length
; i
++) {
501 output
+= isFunction(array
[i
])
502 ? array
[i
].call(mom
, format
)
509 // format date using native date object
510 function formatMoment(m
, format
) {
512 return m
.localeData().invalidDate();
515 format
= expandFormat(format
, m
.localeData());
516 formatFunctions
[format
] =
517 formatFunctions
[format
] || makeFormatFunction(format
);
519 return formatFunctions
[format
](m
);
522 function expandFormat(format
, locale
) {
525 function replaceLongDateFormatTokens(input
) {
526 return locale
.longDateFormat(input
) || input
;
529 localFormattingTokens
.lastIndex
= 0;
530 while (i
>= 0 && localFormattingTokens
.test(format
)) {
531 format
= format
.replace(
532 localFormattingTokens
,
533 replaceLongDateFormatTokens
535 localFormattingTokens
.lastIndex
= 0;
542 var defaultLongDateFormat
= {
547 LLL
: 'MMMM D, YYYY h:mm A',
548 LLLL
: 'dddd, MMMM D, YYYY h:mm A',
551 function longDateFormat(key
) {
552 var format
= this._longDateFormat
[key
],
553 formatUpper
= this._longDateFormat
[key
.toUpperCase()];
555 if (format
|| !formatUpper
) {
559 this._longDateFormat
[key
] = formatUpper
560 .match(formattingTokens
)
561 .map(function (tok
) {
574 return this._longDateFormat
[key
];
577 var defaultInvalidDate
= 'Invalid date';
579 function invalidDate() {
580 return this._invalidDate
;
583 var defaultOrdinal
= '%d',
584 defaultDayOfMonthOrdinalParse
= /\d{1,2}/;
586 function ordinal(number
) {
587 return this._ordinal
.replace('%d', number
);
590 var defaultRelativeTime
= {
609 function relativeTime(number
, withoutSuffix
, string
, isFuture
) {
610 var output
= this._relativeTime
[string
];
611 return isFunction(output
)
612 ? output(number
, withoutSuffix
, string
, isFuture
)
613 : output
.replace(/%d/i, number
);
616 function pastFuture(diff
, output
) {
617 var format
= this._relativeTime
[diff
> 0 ? 'future' : 'past'];
618 return isFunction(format
) ? format(output
) : format
.replace(/%s/i, output
);
623 function addUnitAlias(unit
, shorthand
) {
624 var lowerCase
= unit
.toLowerCase();
625 aliases
[lowerCase
] = aliases
[lowerCase
+ 's'] = aliases
[shorthand
] = unit
;
628 function normalizeUnits(units
) {
629 return typeof units
=== 'string'
630 ? aliases
[units
] || aliases
[units
.toLowerCase()]
634 function normalizeObjectUnits(inputObject
) {
635 var normalizedInput
= {},
639 for (prop
in inputObject
) {
640 if (hasOwnProp(inputObject
, prop
)) {
641 normalizedProp
= normalizeUnits(prop
);
642 if (normalizedProp
) {
643 normalizedInput
[normalizedProp
] = inputObject
[prop
];
648 return normalizedInput
;
653 function addUnitPriority(unit
, priority
) {
654 priorities
[unit
] = priority
;
657 function getPrioritizedUnits(unitsObj
) {
660 for (u
in unitsObj
) {
661 if (hasOwnProp(unitsObj
, u
)) {
662 units
.push({ unit
: u
, priority
: priorities
[u
] });
665 units
.sort(function (a
, b
) {
666 return a
.priority
- b
.priority
;
671 function isLeapYear(year
) {
672 return (year
% 4 === 0 && year
% 100 !== 0) || year
% 400 === 0;
675 function absFloor(number
) {
678 return Math
.ceil(number
) || 0;
680 return Math
.floor(number
);
684 function toInt(argumentForCoercion
) {
685 var coercedNumber
= +argumentForCoercion
,
688 if (coercedNumber
!== 0 && isFinite(coercedNumber
)) {
689 value
= absFloor(coercedNumber
);
695 function makeGetSet(unit
, keepTime
) {
696 return function (value
) {
698 set$1(this, unit
, value
);
699 hooks
.updateOffset(this, keepTime
);
702 return get(this, unit
);
707 function get(mom
, unit
) {
709 ? mom
._d
['get' + (mom
._isUTC
? 'UTC' : '') + unit
]()
713 function set$1(mom
, unit
, value
) {
714 if (mom
.isValid() && !isNaN(value
)) {
716 unit
=== 'FullYear' &&
717 isLeapYear(mom
.year()) &&
721 value
= toInt(value
);
722 mom
._d
['set' + (mom
._isUTC
? 'UTC' : '') + unit
](
725 daysInMonth(value
, mom
.month())
728 mom
._d
['set' + (mom
._isUTC
? 'UTC' : '') + unit
](value
);
735 function stringGet(units
) {
736 units
= normalizeUnits(units
);
737 if (isFunction(this[units
])) {
738 return this[units
]();
743 function stringSet(units
, value
) {
744 if (typeof units
=== 'object') {
745 units
= normalizeObjectUnits(units
);
746 var prioritized
= getPrioritizedUnits(units
),
748 for (i
= 0; i
< prioritized
.length
; i
++) {
749 this[prioritized
[i
].unit
](units
[prioritized
[i
].unit
]);
752 units
= normalizeUnits(units
);
753 if (isFunction(this[units
])) {
754 return this[units
](value
);
760 var match1
= /\d/, // 0 - 9
761 match2
= /\d\d/, // 00 - 99
762 match3
= /\d{3}/, // 000 - 999
763 match4
= /\d{4}/, // 0000 - 9999
764 match6
= /[+-]?\d{6}/, // -999999 - 999999
765 match1to2
= /\d\d?/, // 0 - 99
766 match3to4
= /\d\d\d\d?/, // 999 - 9999
767 match5to6
= /\d\d\d\d\d\d?/, // 99999 - 999999
768 match1to3
= /\d{1,3}/, // 0 - 999
769 match1to4
= /\d{1,4}/, // 0 - 9999
770 match1to6
= /[+-]?\d{1,6}/, // -999999 - 999999
771 matchUnsigned
= /\d+/, // 0 - inf
772 matchSigned
= /[+-]?\d+/, // -inf - inf
773 matchOffset
= /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
774 matchShortOffset
= /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
775 matchTimestamp
= /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
776 // any word (or two) characters or numbers including two/three word month in arabic.
777 // includes scottish gaelic two word and hyphenated months
778 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,
783 function addRegexToken(token
, regex
, strictRegex
) {
784 regexes
[token
] = isFunction(regex
)
786 : function (isStrict
, localeData
) {
787 return isStrict
&& strictRegex
? strictRegex
: regex
;
791 function getParseRegexForToken(token
, config
) {
792 if (!hasOwnProp(regexes
, token
)) {
793 return new RegExp(unescapeFormat(token
));
796 return regexes
[token
](config
._strict
, config
._locale
);
799 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
800 function unescapeFormat(s
) {
804 .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
811 return p1
|| p2
|| p3
|| p4
;
816 function regexEscape(s
) {
817 return s
.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
822 function addParseToken(token
, callback
) {
825 if (typeof token
=== 'string') {
828 if (isNumber(callback
)) {
829 func = function (input
, array
) {
830 array
[callback
] = toInt(input
);
833 for (i
= 0; i
< token
.length
; i
++) {
834 tokens
[token
[i
]] = func
;
838 function addWeekParseToken(token
, callback
) {
839 addParseToken(token
, function (input
, array
, config
, token
) {
840 config
._w
= config
._w
|| {};
841 callback(input
, config
._w
, config
, token
);
845 function addTimeToArrayFromToken(token
, input
, config
) {
846 if (input
!= null && hasOwnProp(tokens
, token
)) {
847 tokens
[token
](input
, config
._a
, config
, token
);
862 return ((n
% x
) + x
) % x
;
867 if (Array
.prototype.indexOf
) {
868 indexOf
= Array
.prototype.indexOf
;
870 indexOf = function (o
) {
873 for (i
= 0; i
< this.length
; ++i
) {
882 function daysInMonth(year
, month
) {
883 if (isNaN(year
) || isNaN(month
)) {
886 var modMonth
= mod(month
, 12);
887 year
+= (month
- modMonth
) / 12;
888 return modMonth
=== 1
892 : 31 - ((modMonth
% 7) % 2);
897 addFormatToken('M', ['MM', 2], 'Mo', function () {
898 return this.month() + 1;
901 addFormatToken('MMM', 0, 0, function (format
) {
902 return this.localeData().monthsShort(this, format
);
905 addFormatToken('MMMM', 0, 0, function (format
) {
906 return this.localeData().months(this, format
);
911 addUnitAlias('month', 'M');
915 addUnitPriority('month', 8);
919 addRegexToken('M', match1to2
);
920 addRegexToken('MM', match1to2
, match2
);
921 addRegexToken('MMM', function (isStrict
, locale
) {
922 return locale
.monthsShortRegex(isStrict
);
924 addRegexToken('MMMM', function (isStrict
, locale
) {
925 return locale
.monthsRegex(isStrict
);
928 addParseToken(['M', 'MM'], function (input
, array
) {
929 array
[MONTH
] = toInt(input
) - 1;
932 addParseToken(['MMM', 'MMMM'], function (input
, array
, config
, token
) {
933 var month
= config
._locale
.monthsParse(input
, token
, config
._strict
);
934 // if we didn't find a month name, mark the date as invalid.
936 array
[MONTH
] = month
;
938 getParsingFlags(config
).invalidMonth
= input
;
944 var defaultLocaleMonths
= 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
947 defaultLocaleMonthsShort
= 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
950 MONTHS_IN_FORMAT
= /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
951 defaultMonthsShortRegex
= matchWord
,
952 defaultMonthsRegex
= matchWord
;
954 function localeMonths(m
, format
) {
956 return isArray(this._months
)
958 : this._months
['standalone'];
960 return isArray(this._months
)
961 ? this._months
[m
.month()]
963 (this._months
.isFormat
|| MONTHS_IN_FORMAT
).test(format
)
969 function localeMonthsShort(m
, format
) {
971 return isArray(this._monthsShort
)
973 : this._monthsShort
['standalone'];
975 return isArray(this._monthsShort
)
976 ? this._monthsShort
[m
.month()]
978 MONTHS_IN_FORMAT
.test(format
) ? 'format' : 'standalone'
982 function handleStrictParse(monthName
, format
, strict
) {
986 llc
= monthName
.toLocaleLowerCase();
987 if (!this._monthsParse
) {
989 this._monthsParse
= [];
990 this._longMonthsParse
= [];
991 this._shortMonthsParse
= [];
992 for (i
= 0; i
< 12; ++i
) {
993 mom
= createUTC([2000, i
]);
994 this._shortMonthsParse
[i
] = this.monthsShort(
997 ).toLocaleLowerCase();
998 this._longMonthsParse
[i
] = this.months(mom
, '').toLocaleLowerCase();
1003 if (format
=== 'MMM') {
1004 ii
= indexOf
.call(this._shortMonthsParse
, llc
);
1005 return ii
!== -1 ? ii
: null;
1007 ii
= indexOf
.call(this._longMonthsParse
, llc
);
1008 return ii
!== -1 ? ii
: null;
1011 if (format
=== 'MMM') {
1012 ii
= indexOf
.call(this._shortMonthsParse
, llc
);
1016 ii
= indexOf
.call(this._longMonthsParse
, llc
);
1017 return ii
!== -1 ? ii
: null;
1019 ii
= indexOf
.call(this._longMonthsParse
, llc
);
1023 ii
= indexOf
.call(this._shortMonthsParse
, llc
);
1024 return ii
!== -1 ? ii
: null;
1029 function localeMonthsParse(monthName
, format
, strict
) {
1032 if (this._monthsParseExact
) {
1033 return handleStrictParse
.call(this, monthName
, format
, strict
);
1036 if (!this._monthsParse
) {
1037 this._monthsParse
= [];
1038 this._longMonthsParse
= [];
1039 this._shortMonthsParse
= [];
1042 // TODO: add sorting
1043 // Sorting makes sure if one month (or abbr) is a prefix of another
1044 // see sorting in computeMonthsParse
1045 for (i
= 0; i
< 12; i
++) {
1046 // make the regex if we don't have it already
1047 mom
= createUTC([2000, i
]);
1048 if (strict
&& !this._longMonthsParse
[i
]) {
1049 this._longMonthsParse
[i
] = new RegExp(
1050 '^' + this.months(mom
, '').replace('.', '') + '$',
1053 this._shortMonthsParse
[i
] = new RegExp(
1054 '^' + this.monthsShort(mom
, '').replace('.', '') + '$',
1058 if (!strict
&& !this._monthsParse
[i
]) {
1060 '^' + this.months(mom
, '') + '|^' + this.monthsShort(mom
, '');
1061 this._monthsParse
[i
] = new RegExp(regex
.replace('.', ''), 'i');
1066 format
=== 'MMMM' &&
1067 this._longMonthsParse
[i
].test(monthName
)
1073 this._shortMonthsParse
[i
].test(monthName
)
1076 } else if (!strict
&& this._monthsParse
[i
].test(monthName
)) {
1084 function setMonth(mom
, value
) {
1087 if (!mom
.isValid()) {
1092 if (typeof value
=== 'string') {
1093 if (/^\d+$/.test(value
)) {
1094 value
= toInt(value
);
1096 value
= mom
.localeData().monthsParse(value
);
1097 // TODO: Another silent failure?
1098 if (!isNumber(value
)) {
1104 dayOfMonth
= Math
.min(mom
.date(), daysInMonth(mom
.year(), value
));
1105 mom
._d
['set' + (mom
._isUTC
? 'UTC' : '') + 'Month'](value
, dayOfMonth
);
1109 function getSetMonth(value
) {
1110 if (value
!= null) {
1111 setMonth(this, value
);
1112 hooks
.updateOffset(this, true);
1115 return get(this, 'Month');
1119 function getDaysInMonth() {
1120 return daysInMonth(this.year(), this.month());
1123 function monthsShortRegex(isStrict
) {
1124 if (this._monthsParseExact
) {
1125 if (!hasOwnProp(this, '_monthsRegex')) {
1126 computeMonthsParse
.call(this);
1129 return this._monthsShortStrictRegex
;
1131 return this._monthsShortRegex
;
1134 if (!hasOwnProp(this, '_monthsShortRegex')) {
1135 this._monthsShortRegex
= defaultMonthsShortRegex
;
1137 return this._monthsShortStrictRegex
&& isStrict
1138 ? this._monthsShortStrictRegex
1139 : this._monthsShortRegex
;
1143 function monthsRegex(isStrict
) {
1144 if (this._monthsParseExact
) {
1145 if (!hasOwnProp(this, '_monthsRegex')) {
1146 computeMonthsParse
.call(this);
1149 return this._monthsStrictRegex
;
1151 return this._monthsRegex
;
1154 if (!hasOwnProp(this, '_monthsRegex')) {
1155 this._monthsRegex
= defaultMonthsRegex
;
1157 return this._monthsStrictRegex
&& isStrict
1158 ? this._monthsStrictRegex
1159 : this._monthsRegex
;
1163 function computeMonthsParse() {
1164 function cmpLenRev(a
, b
) {
1165 return b
.length
- a
.length
;
1168 var shortPieces
= [],
1173 for (i
= 0; i
< 12; i
++) {
1174 // make the regex if we don't have it already
1175 mom
= createUTC([2000, i
]);
1176 shortPieces
.push(this.monthsShort(mom
, ''));
1177 longPieces
.push(this.months(mom
, ''));
1178 mixedPieces
.push(this.months(mom
, ''));
1179 mixedPieces
.push(this.monthsShort(mom
, ''));
1181 // Sorting makes sure if one month (or abbr) is a prefix of another it
1182 // will match the longer piece.
1183 shortPieces
.sort(cmpLenRev
);
1184 longPieces
.sort(cmpLenRev
);
1185 mixedPieces
.sort(cmpLenRev
);
1186 for (i
= 0; i
< 12; i
++) {
1187 shortPieces
[i
] = regexEscape(shortPieces
[i
]);
1188 longPieces
[i
] = regexEscape(longPieces
[i
]);
1190 for (i
= 0; i
< 24; i
++) {
1191 mixedPieces
[i
] = regexEscape(mixedPieces
[i
]);
1194 this._monthsRegex
= new RegExp('^(' + mixedPieces
.join('|') + ')', 'i');
1195 this._monthsShortRegex
= this._monthsRegex
;
1196 this._monthsStrictRegex
= new RegExp(
1197 '^(' + longPieces
.join('|') + ')',
1200 this._monthsShortStrictRegex
= new RegExp(
1201 '^(' + shortPieces
.join('|') + ')',
1208 addFormatToken('Y', 0, 0, function () {
1209 var y
= this.year();
1210 return y
<= 9999 ? zeroFill(y
, 4) : '+' + y
;
1213 addFormatToken(0, ['YY', 2], 0, function () {
1214 return this.year() % 100;
1217 addFormatToken(0, ['YYYY', 4], 0, 'year');
1218 addFormatToken(0, ['YYYYY', 5], 0, 'year');
1219 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
1223 addUnitAlias('year', 'y');
1227 addUnitPriority('year', 1);
1231 addRegexToken('Y', matchSigned
);
1232 addRegexToken('YY', match1to2
, match2
);
1233 addRegexToken('YYYY', match1to4
, match4
);
1234 addRegexToken('YYYYY', match1to6
, match6
);
1235 addRegexToken('YYYYYY', match1to6
, match6
);
1237 addParseToken(['YYYYY', 'YYYYYY'], YEAR
);
1238 addParseToken('YYYY', function (input
, array
) {
1240 input
.length
=== 2 ? hooks
.parseTwoDigitYear(input
) : toInt(input
);
1242 addParseToken('YY', function (input
, array
) {
1243 array
[YEAR
] = hooks
.parseTwoDigitYear(input
);
1245 addParseToken('Y', function (input
, array
) {
1246 array
[YEAR
] = parseInt(input
, 10);
1251 function daysInYear(year
) {
1252 return isLeapYear(year
) ? 366 : 365;
1257 hooks
.parseTwoDigitYear = function (input
) {
1258 return toInt(input
) + (toInt(input
) > 68 ? 1900 : 2000);
1263 var getSetYear
= makeGetSet('FullYear', true);
1265 function getIsLeapYear() {
1266 return isLeapYear(this.year());
1269 function createDate(y
, m
, d
, h
, M
, s
, ms
) {
1270 // can't just apply() to create a date:
1271 // https://stackoverflow.com/q/181348
1273 // the date constructor remaps years 0-99 to 1900-1999
1274 if (y
< 100 && y
>= 0) {
1275 // preserve leap years using a full 400 year cycle, then reset
1276 date
= new Date(y
+ 400, m
, d
, h
, M
, s
, ms
);
1277 if (isFinite(date
.getFullYear())) {
1278 date
.setFullYear(y
);
1281 date
= new Date(y
, m
, d
, h
, M
, s
, ms
);
1287 function createUTCDate(y
) {
1289 // the Date.UTC function remaps years 0-99 to 1900-1999
1290 if (y
< 100 && y
>= 0) {
1291 args
= Array
.prototype.slice
.call(arguments
);
1292 // preserve leap years using a full 400 year cycle, then reset
1294 date
= new Date(Date
.UTC
.apply(null, args
));
1295 if (isFinite(date
.getUTCFullYear())) {
1296 date
.setUTCFullYear(y
);
1299 date
= new Date(Date
.UTC
.apply(null, arguments
));
1305 // start-of-first-week - start-of-year
1306 function firstWeekOffset(year
, dow
, doy
) {
1307 var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
1308 fwd
= 7 + dow
- doy
,
1309 // first-week day local weekday -- which local weekday is fwd
1310 fwdlw
= (7 + createUTCDate(year
, 0, fwd
).getUTCDay() - dow
) % 7;
1312 return -fwdlw
+ fwd
- 1;
1315 // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
1316 function dayOfYearFromWeeks(year
, week
, weekday
, dow
, doy
) {
1317 var localWeekday
= (7 + weekday
- dow
) % 7,
1318 weekOffset
= firstWeekOffset(year
, dow
, doy
),
1319 dayOfYear
= 1 + 7 * (week
- 1) + localWeekday
+ weekOffset
,
1323 if (dayOfYear
<= 0) {
1325 resDayOfYear
= daysInYear(resYear
) + dayOfYear
;
1326 } else if (dayOfYear
> daysInYear(year
)) {
1328 resDayOfYear
= dayOfYear
- daysInYear(year
);
1331 resDayOfYear
= dayOfYear
;
1336 dayOfYear
: resDayOfYear
,
1340 function weekOfYear(mom
, dow
, doy
) {
1341 var weekOffset
= firstWeekOffset(mom
.year(), dow
, doy
),
1342 week
= Math
.floor((mom
.dayOfYear() - weekOffset
- 1) / 7) + 1,
1347 resYear
= mom
.year() - 1;
1348 resWeek
= week
+ weeksInYear(resYear
, dow
, doy
);
1349 } else if (week
> weeksInYear(mom
.year(), dow
, doy
)) {
1350 resWeek
= week
- weeksInYear(mom
.year(), dow
, doy
);
1351 resYear
= mom
.year() + 1;
1353 resYear
= mom
.year();
1363 function weeksInYear(year
, dow
, doy
) {
1364 var weekOffset
= firstWeekOffset(year
, dow
, doy
),
1365 weekOffsetNext
= firstWeekOffset(year
+ 1, dow
, doy
);
1366 return (daysInYear(year
) - weekOffset
+ weekOffsetNext
) / 7;
1371 addFormatToken('w', ['ww', 2], 'wo', 'week');
1372 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
1376 addUnitAlias('week', 'w');
1377 addUnitAlias('isoWeek', 'W');
1381 addUnitPriority('week', 5);
1382 addUnitPriority('isoWeek', 5);
1386 addRegexToken('w', match1to2
);
1387 addRegexToken('ww', match1to2
, match2
);
1388 addRegexToken('W', match1to2
);
1389 addRegexToken('WW', match1to2
, match2
);
1391 addWeekParseToken(['w', 'ww', 'W', 'WW'], function (
1397 week
[token
.substr(0, 1)] = toInt(input
);
1404 function localeWeek(mom
) {
1405 return weekOfYear(mom
, this._week
.dow
, this._week
.doy
).week
;
1408 var defaultLocaleWeek
= {
1409 dow
: 0, // Sunday is the first day of the week.
1410 doy
: 6, // The week that contains Jan 6th is the first week of the year.
1413 function localeFirstDayOfWeek() {
1414 return this._week
.dow
;
1417 function localeFirstDayOfYear() {
1418 return this._week
.doy
;
1423 function getSetWeek(input
) {
1424 var week
= this.localeData().week(this);
1425 return input
== null ? week
: this.add((input
- week
) * 7, 'd');
1428 function getSetISOWeek(input
) {
1429 var week
= weekOfYear(this, 1, 4).week
;
1430 return input
== null ? week
: this.add((input
- week
) * 7, 'd');
1435 addFormatToken('d', 0, 'do', 'day');
1437 addFormatToken('dd', 0, 0, function (format
) {
1438 return this.localeData().weekdaysMin(this, format
);
1441 addFormatToken('ddd', 0, 0, function (format
) {
1442 return this.localeData().weekdaysShort(this, format
);
1445 addFormatToken('dddd', 0, 0, function (format
) {
1446 return this.localeData().weekdays(this, format
);
1449 addFormatToken('e', 0, 0, 'weekday');
1450 addFormatToken('E', 0, 0, 'isoWeekday');
1454 addUnitAlias('day', 'd');
1455 addUnitAlias('weekday', 'e');
1456 addUnitAlias('isoWeekday', 'E');
1459 addUnitPriority('day', 11);
1460 addUnitPriority('weekday', 11);
1461 addUnitPriority('isoWeekday', 11);
1465 addRegexToken('d', match1to2
);
1466 addRegexToken('e', match1to2
);
1467 addRegexToken('E', match1to2
);
1468 addRegexToken('dd', function (isStrict
, locale
) {
1469 return locale
.weekdaysMinRegex(isStrict
);
1471 addRegexToken('ddd', function (isStrict
, locale
) {
1472 return locale
.weekdaysShortRegex(isStrict
);
1474 addRegexToken('dddd', function (isStrict
, locale
) {
1475 return locale
.weekdaysRegex(isStrict
);
1478 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input
, week
, config
, token
) {
1479 var weekday
= config
._locale
.weekdaysParse(input
, token
, config
._strict
);
1480 // if we didn't get a weekday name, mark the date as invalid
1481 if (weekday
!= null) {
1484 getParsingFlags(config
).invalidWeekday
= input
;
1488 addWeekParseToken(['d', 'e', 'E'], function (input
, week
, config
, token
) {
1489 week
[token
] = toInt(input
);
1494 function parseWeekday(input
, locale
) {
1495 if (typeof input
!== 'string') {
1499 if (!isNaN(input
)) {
1500 return parseInt(input
, 10);
1503 input
= locale
.weekdaysParse(input
);
1504 if (typeof input
=== 'number') {
1511 function parseIsoWeekday(input
, locale
) {
1512 if (typeof input
=== 'string') {
1513 return locale
.weekdaysParse(input
) % 7 || 7;
1515 return isNaN(input
) ? null : input
;
1519 function shiftWeekdays(ws
, n
) {
1520 return ws
.slice(n
, 7).concat(ws
.slice(0, n
));
1523 var defaultLocaleWeekdays
= 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
1526 defaultLocaleWeekdaysShort
= 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
1527 defaultLocaleWeekdaysMin
= 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
1528 defaultWeekdaysRegex
= matchWord
,
1529 defaultWeekdaysShortRegex
= matchWord
,
1530 defaultWeekdaysMinRegex
= matchWord
;
1532 function localeWeekdays(m
, format
) {
1533 var weekdays
= isArray(this._weekdays
)
1536 m
&& m
!== true && this._weekdays
.isFormat
.test(format
)
1541 ? shiftWeekdays(weekdays
, this._week
.dow
)
1547 function localeWeekdaysShort(m
) {
1549 ? shiftWeekdays(this._weekdaysShort
, this._week
.dow
)
1551 ? this._weekdaysShort
[m
.day()]
1552 : this._weekdaysShort
;
1555 function localeWeekdaysMin(m
) {
1557 ? shiftWeekdays(this._weekdaysMin
, this._week
.dow
)
1559 ? this._weekdaysMin
[m
.day()]
1560 : this._weekdaysMin
;
1563 function handleStrictParse
$1(weekdayName
, format
, strict
) {
1567 llc
= weekdayName
.toLocaleLowerCase();
1568 if (!this._weekdaysParse
) {
1569 this._weekdaysParse
= [];
1570 this._shortWeekdaysParse
= [];
1571 this._minWeekdaysParse
= [];
1573 for (i
= 0; i
< 7; ++i
) {
1574 mom
= createUTC([2000, 1]).day(i
);
1575 this._minWeekdaysParse
[i
] = this.weekdaysMin(
1578 ).toLocaleLowerCase();
1579 this._shortWeekdaysParse
[i
] = this.weekdaysShort(
1582 ).toLocaleLowerCase();
1583 this._weekdaysParse
[i
] = this.weekdays(mom
, '').toLocaleLowerCase();
1588 if (format
=== 'dddd') {
1589 ii
= indexOf
.call(this._weekdaysParse
, llc
);
1590 return ii
!== -1 ? ii
: null;
1591 } else if (format
=== 'ddd') {
1592 ii
= indexOf
.call(this._shortWeekdaysParse
, llc
);
1593 return ii
!== -1 ? ii
: null;
1595 ii
= indexOf
.call(this._minWeekdaysParse
, llc
);
1596 return ii
!== -1 ? ii
: null;
1599 if (format
=== 'dddd') {
1600 ii
= indexOf
.call(this._weekdaysParse
, llc
);
1604 ii
= indexOf
.call(this._shortWeekdaysParse
, llc
);
1608 ii
= indexOf
.call(this._minWeekdaysParse
, llc
);
1609 return ii
!== -1 ? ii
: null;
1610 } else if (format
=== 'ddd') {
1611 ii
= indexOf
.call(this._shortWeekdaysParse
, llc
);
1615 ii
= indexOf
.call(this._weekdaysParse
, llc
);
1619 ii
= indexOf
.call(this._minWeekdaysParse
, llc
);
1620 return ii
!== -1 ? ii
: null;
1622 ii
= indexOf
.call(this._minWeekdaysParse
, llc
);
1626 ii
= indexOf
.call(this._weekdaysParse
, llc
);
1630 ii
= indexOf
.call(this._shortWeekdaysParse
, llc
);
1631 return ii
!== -1 ? ii
: null;
1636 function localeWeekdaysParse(weekdayName
, format
, strict
) {
1639 if (this._weekdaysParseExact
) {
1640 return handleStrictParse
$1.call(this, weekdayName
, format
, strict
);
1643 if (!this._weekdaysParse
) {
1644 this._weekdaysParse
= [];
1645 this._minWeekdaysParse
= [];
1646 this._shortWeekdaysParse
= [];
1647 this._fullWeekdaysParse
= [];
1650 for (i
= 0; i
< 7; i
++) {
1651 // make the regex if we don't have it already
1653 mom
= createUTC([2000, 1]).day(i
);
1654 if (strict
&& !this._fullWeekdaysParse
[i
]) {
1655 this._fullWeekdaysParse
[i
] = new RegExp(
1656 '^' + this.weekdays(mom
, '').replace('.', '\\.?') + '$',
1659 this._shortWeekdaysParse
[i
] = new RegExp(
1660 '^' + this.weekdaysShort(mom
, '').replace('.', '\\.?') + '$',
1663 this._minWeekdaysParse
[i
] = new RegExp(
1664 '^' + this.weekdaysMin(mom
, '').replace('.', '\\.?') + '$',
1668 if (!this._weekdaysParse
[i
]) {
1671 this.weekdays(mom
, '') +
1673 this.weekdaysShort(mom
, '') +
1675 this.weekdaysMin(mom
, '');
1676 this._weekdaysParse
[i
] = new RegExp(regex
.replace('.', ''), 'i');
1681 format
=== 'dddd' &&
1682 this._fullWeekdaysParse
[i
].test(weekdayName
)
1688 this._shortWeekdaysParse
[i
].test(weekdayName
)
1694 this._minWeekdaysParse
[i
].test(weekdayName
)
1697 } else if (!strict
&& this._weekdaysParse
[i
].test(weekdayName
)) {
1705 function getSetDayOfWeek(input
) {
1706 if (!this.isValid()) {
1707 return input
!= null ? this : NaN
;
1709 var day
= this._isUTC
? this._d
.getUTCDay() : this._d
.getDay();
1710 if (input
!= null) {
1711 input
= parseWeekday(input
, this.localeData());
1712 return this.add(input
- day
, 'd');
1718 function getSetLocaleDayOfWeek(input
) {
1719 if (!this.isValid()) {
1720 return input
!= null ? this : NaN
;
1722 var weekday
= (this.day() + 7 - this.localeData()._week
.dow
) % 7;
1723 return input
== null ? weekday
: this.add(input
- weekday
, 'd');
1726 function getSetISODayOfWeek(input
) {
1727 if (!this.isValid()) {
1728 return input
!= null ? this : NaN
;
1731 // behaves the same as moment#day except
1732 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
1733 // as a setter, sunday should belong to the previous week.
1735 if (input
!= null) {
1736 var weekday
= parseIsoWeekday(input
, this.localeData());
1737 return this.day(this.day() % 7 ? weekday
: weekday
- 7);
1739 return this.day() || 7;
1743 function weekdaysRegex(isStrict
) {
1744 if (this._weekdaysParseExact
) {
1745 if (!hasOwnProp(this, '_weekdaysRegex')) {
1746 computeWeekdaysParse
.call(this);
1749 return this._weekdaysStrictRegex
;
1751 return this._weekdaysRegex
;
1754 if (!hasOwnProp(this, '_weekdaysRegex')) {
1755 this._weekdaysRegex
= defaultWeekdaysRegex
;
1757 return this._weekdaysStrictRegex
&& isStrict
1758 ? this._weekdaysStrictRegex
1759 : this._weekdaysRegex
;
1763 function weekdaysShortRegex(isStrict
) {
1764 if (this._weekdaysParseExact
) {
1765 if (!hasOwnProp(this, '_weekdaysRegex')) {
1766 computeWeekdaysParse
.call(this);
1769 return this._weekdaysShortStrictRegex
;
1771 return this._weekdaysShortRegex
;
1774 if (!hasOwnProp(this, '_weekdaysShortRegex')) {
1775 this._weekdaysShortRegex
= defaultWeekdaysShortRegex
;
1777 return this._weekdaysShortStrictRegex
&& isStrict
1778 ? this._weekdaysShortStrictRegex
1779 : this._weekdaysShortRegex
;
1783 function weekdaysMinRegex(isStrict
) {
1784 if (this._weekdaysParseExact
) {
1785 if (!hasOwnProp(this, '_weekdaysRegex')) {
1786 computeWeekdaysParse
.call(this);
1789 return this._weekdaysMinStrictRegex
;
1791 return this._weekdaysMinRegex
;
1794 if (!hasOwnProp(this, '_weekdaysMinRegex')) {
1795 this._weekdaysMinRegex
= defaultWeekdaysMinRegex
;
1797 return this._weekdaysMinStrictRegex
&& isStrict
1798 ? this._weekdaysMinStrictRegex
1799 : this._weekdaysMinRegex
;
1803 function computeWeekdaysParse() {
1804 function cmpLenRev(a
, b
) {
1805 return b
.length
- a
.length
;
1817 for (i
= 0; i
< 7; i
++) {
1818 // make the regex if we don't have it already
1819 mom
= createUTC([2000, 1]).day(i
);
1820 minp
= regexEscape(this.weekdaysMin(mom
, ''));
1821 shortp
= regexEscape(this.weekdaysShort(mom
, ''));
1822 longp
= regexEscape(this.weekdays(mom
, ''));
1823 minPieces
.push(minp
);
1824 shortPieces
.push(shortp
);
1825 longPieces
.push(longp
);
1826 mixedPieces
.push(minp
);
1827 mixedPieces
.push(shortp
);
1828 mixedPieces
.push(longp
);
1830 // Sorting makes sure if one weekday (or abbr) is a prefix of another it
1831 // will match the longer piece.
1832 minPieces
.sort(cmpLenRev
);
1833 shortPieces
.sort(cmpLenRev
);
1834 longPieces
.sort(cmpLenRev
);
1835 mixedPieces
.sort(cmpLenRev
);
1837 this._weekdaysRegex
= new RegExp('^(' + mixedPieces
.join('|') + ')', 'i');
1838 this._weekdaysShortRegex
= this._weekdaysRegex
;
1839 this._weekdaysMinRegex
= this._weekdaysRegex
;
1841 this._weekdaysStrictRegex
= new RegExp(
1842 '^(' + longPieces
.join('|') + ')',
1845 this._weekdaysShortStrictRegex
= new RegExp(
1846 '^(' + shortPieces
.join('|') + ')',
1849 this._weekdaysMinStrictRegex
= new RegExp(
1850 '^(' + minPieces
.join('|') + ')',
1857 function hFormat() {
1858 return this.hours() % 12 || 12;
1861 function kFormat() {
1862 return this.hours() || 24;
1865 addFormatToken('H', ['HH', 2], 0, 'hour');
1866 addFormatToken('h', ['hh', 2], 0, hFormat
);
1867 addFormatToken('k', ['kk', 2], 0, kFormat
);
1869 addFormatToken('hmm', 0, 0, function () {
1870 return '' + hFormat
.apply(this) + zeroFill(this.minutes(), 2);
1873 addFormatToken('hmmss', 0, 0, function () {
1876 hFormat
.apply(this) +
1877 zeroFill(this.minutes(), 2) +
1878 zeroFill(this.seconds(), 2)
1882 addFormatToken('Hmm', 0, 0, function () {
1883 return '' + this.hours() + zeroFill(this.minutes(), 2);
1886 addFormatToken('Hmmss', 0, 0, function () {
1890 zeroFill(this.minutes(), 2) +
1891 zeroFill(this.seconds(), 2)
1895 function meridiem(token
, lowercase
) {
1896 addFormatToken(token
, 0, 0, function () {
1897 return this.localeData().meridiem(
1905 meridiem('a', true);
1906 meridiem('A', false);
1910 addUnitAlias('hour', 'h');
1913 addUnitPriority('hour', 13);
1917 function matchMeridiem(isStrict
, locale
) {
1918 return locale
._meridiemParse
;
1921 addRegexToken('a', matchMeridiem
);
1922 addRegexToken('A', matchMeridiem
);
1923 addRegexToken('H', match1to2
);
1924 addRegexToken('h', match1to2
);
1925 addRegexToken('k', match1to2
);
1926 addRegexToken('HH', match1to2
, match2
);
1927 addRegexToken('hh', match1to2
, match2
);
1928 addRegexToken('kk', match1to2
, match2
);
1930 addRegexToken('hmm', match3to4
);
1931 addRegexToken('hmmss', match5to6
);
1932 addRegexToken('Hmm', match3to4
);
1933 addRegexToken('Hmmss', match5to6
);
1935 addParseToken(['H', 'HH'], HOUR
);
1936 addParseToken(['k', 'kk'], function (input
, array
, config
) {
1937 var kInput
= toInt(input
);
1938 array
[HOUR
] = kInput
=== 24 ? 0 : kInput
;
1940 addParseToken(['a', 'A'], function (input
, array
, config
) {
1941 config
._isPm
= config
._locale
.isPM(input
);
1942 config
._meridiem
= input
;
1944 addParseToken(['h', 'hh'], function (input
, array
, config
) {
1945 array
[HOUR
] = toInt(input
);
1946 getParsingFlags(config
).bigHour
= true;
1948 addParseToken('hmm', function (input
, array
, config
) {
1949 var pos
= input
.length
- 2;
1950 array
[HOUR
] = toInt(input
.substr(0, pos
));
1951 array
[MINUTE
] = toInt(input
.substr(pos
));
1952 getParsingFlags(config
).bigHour
= true;
1954 addParseToken('hmmss', function (input
, array
, config
) {
1955 var pos1
= input
.length
- 4,
1956 pos2
= input
.length
- 2;
1957 array
[HOUR
] = toInt(input
.substr(0, pos1
));
1958 array
[MINUTE
] = toInt(input
.substr(pos1
, 2));
1959 array
[SECOND
] = toInt(input
.substr(pos2
));
1960 getParsingFlags(config
).bigHour
= true;
1962 addParseToken('Hmm', function (input
, array
, config
) {
1963 var pos
= input
.length
- 2;
1964 array
[HOUR
] = toInt(input
.substr(0, pos
));
1965 array
[MINUTE
] = toInt(input
.substr(pos
));
1967 addParseToken('Hmmss', function (input
, array
, config
) {
1968 var pos1
= input
.length
- 4,
1969 pos2
= input
.length
- 2;
1970 array
[HOUR
] = toInt(input
.substr(0, pos1
));
1971 array
[MINUTE
] = toInt(input
.substr(pos1
, 2));
1972 array
[SECOND
] = toInt(input
.substr(pos2
));
1977 function localeIsPM(input
) {
1978 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
1979 // Using charAt should be more compatible.
1980 return (input
+ '').toLowerCase().charAt(0) === 'p';
1983 var defaultLocaleMeridiemParse
= /[ap]\.?m?\.?/i,
1984 // Setting the hour should keep the time, because the user explicitly
1985 // specified which hour they want. So trying to maintain the same hour (in
1986 // a new timezone) makes sense. Adding/subtracting hours does not follow
1988 getSetHour
= makeGetSet('Hours', true);
1990 function localeMeridiem(hours
, minutes
, isLower
) {
1992 return isLower
? 'pm' : 'PM';
1994 return isLower
? 'am' : 'AM';
1999 calendar
: defaultCalendar
,
2000 longDateFormat
: defaultLongDateFormat
,
2001 invalidDate
: defaultInvalidDate
,
2002 ordinal
: defaultOrdinal
,
2003 dayOfMonthOrdinalParse
: defaultDayOfMonthOrdinalParse
,
2004 relativeTime
: defaultRelativeTime
,
2006 months
: defaultLocaleMonths
,
2007 monthsShort
: defaultLocaleMonthsShort
,
2009 week
: defaultLocaleWeek
,
2011 weekdays
: defaultLocaleWeekdays
,
2012 weekdaysMin
: defaultLocaleWeekdaysMin
,
2013 weekdaysShort
: defaultLocaleWeekdaysShort
,
2015 meridiemParse
: defaultLocaleMeridiemParse
,
2018 // internal storage for locale config files
2020 localeFamilies
= {},
2023 function commonPrefix(arr1
, arr2
) {
2025 minl
= Math
.min(arr1
.length
, arr2
.length
);
2026 for (i
= 0; i
< minl
; i
+= 1) {
2027 if (arr1
[i
] !== arr2
[i
]) {
2034 function normalizeLocale(key
) {
2035 return key
? key
.toLowerCase().replace('_', '-') : key
;
2038 // pick the locale from the array
2039 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
2040 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
2041 function chooseLocale(names
) {
2048 while (i
< names
.length
) {
2049 split
= normalizeLocale(names
[i
]).split('-');
2051 next
= normalizeLocale(names
[i
+ 1]);
2052 next
= next
? next
.split('-') : null;
2054 locale
= loadLocale(split
.slice(0, j
).join('-'));
2061 commonPrefix(split
, next
) >= j
- 1
2063 //the next array item is better than a shallower substring of this one
2070 return globalLocale
;
2073 function loadLocale(name
) {
2074 var oldLocale
= null,
2076 // TODO: Find a better way to register and load all the locales in Node
2078 locales
[name
] === undefined &&
2079 typeof module
!== 'undefined' &&
2084 oldLocale
= globalLocale
._abbr
;
2085 aliasedRequire
= require
;
2086 aliasedRequire('./locale/' + name
);
2087 getSetGlobalLocale(oldLocale
);
2089 // mark as not found to avoid repeating expensive file require call causing high CPU
2090 // when trying to find en-US, en_US, en-us for every format call
2091 locales
[name
] = null; // null means not found
2094 return locales
[name
];
2097 // This function will load locale and then set the global locale. If
2098 // no arguments are passed in, it will simply return the current global
2100 function getSetGlobalLocale(key
, values
) {
2103 if (isUndefined(values
)) {
2104 data
= getLocale(key
);
2106 data
= defineLocale(key
, values
);
2110 // moment.duration._locale = moment._locale = data;
2111 globalLocale
= data
;
2113 if (typeof console
!== 'undefined' && console
.warn
) {
2114 //warn user if arguments are passed but the locale could not be set
2116 'Locale ' + key
+ ' not found. Did you forget to load it?'
2122 return globalLocale
._abbr
;
2125 function defineLocale(name
, config
) {
2126 if (config
!== null) {
2128 parentConfig
= baseConfig
;
2130 if (locales
[name
] != null) {
2132 'defineLocaleOverride',
2133 'use moment.updateLocale(localeName, config) to change ' +
2134 'an existing locale. moment.defineLocale(localeName, ' +
2135 'config) should only be used for creating a new locale ' +
2136 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
2138 parentConfig
= locales
[name
]._config
;
2139 } else if (config
.parentLocale
!= null) {
2140 if (locales
[config
.parentLocale
] != null) {
2141 parentConfig
= locales
[config
.parentLocale
]._config
;
2143 locale
= loadLocale(config
.parentLocale
);
2144 if (locale
!= null) {
2145 parentConfig
= locale
._config
;
2147 if (!localeFamilies
[config
.parentLocale
]) {
2148 localeFamilies
[config
.parentLocale
] = [];
2150 localeFamilies
[config
.parentLocale
].push({
2158 locales
[name
] = new Locale(mergeConfigs(parentConfig
, config
));
2160 if (localeFamilies
[name
]) {
2161 localeFamilies
[name
].forEach(function (x
) {
2162 defineLocale(x
.name
, x
.config
);
2166 // backwards compat for now: also set the locale
2167 // make sure we set the locale AFTER all child locales have been
2168 // created, so we won't end up with the child locale set.
2169 getSetGlobalLocale(name
);
2171 return locales
[name
];
2173 // useful for testing
2174 delete locales
[name
];
2179 function updateLocale(name
, config
) {
2180 if (config
!= null) {
2183 parentConfig
= baseConfig
;
2185 if (locales
[name
] != null && locales
[name
].parentLocale
!= null) {
2186 // Update existing child locale in-place to avoid memory-leaks
2187 locales
[name
].set(mergeConfigs(locales
[name
]._config
, config
));
2190 tmpLocale
= loadLocale(name
);
2191 if (tmpLocale
!= null) {
2192 parentConfig
= tmpLocale
._config
;
2194 config
= mergeConfigs(parentConfig
, config
);
2195 if (tmpLocale
== null) {
2196 // updateLocale is called for creating a new locale
2197 // Set abbr so it will have a name (getters return
2198 // undefined otherwise).
2201 locale
= new Locale(config
);
2202 locale
.parentLocale
= locales
[name
];
2203 locales
[name
] = locale
;
2206 // backwards compat for now: also set the locale
2207 getSetGlobalLocale(name
);
2209 // pass null for config to unupdate, useful for tests
2210 if (locales
[name
] != null) {
2211 if (locales
[name
].parentLocale
!= null) {
2212 locales
[name
] = locales
[name
].parentLocale
;
2213 if (name
=== getSetGlobalLocale()) {
2214 getSetGlobalLocale(name
);
2216 } else if (locales
[name
] != null) {
2217 delete locales
[name
];
2221 return locales
[name
];
2224 // returns locale data
2225 function getLocale(key
) {
2228 if (key
&& key
._locale
&& key
._locale
._abbr
) {
2229 key
= key
._locale
._abbr
;
2233 return globalLocale
;
2236 if (!isArray(key
)) {
2237 //short-circuit everything else
2238 locale
= loadLocale(key
);
2245 return chooseLocale(key
);
2248 function listLocales() {
2249 return keys(locales
);
2252 function checkOverflow(m
) {
2256 if (a
&& getParsingFlags(m
).overflow
=== -2) {
2258 a
[MONTH
] < 0 || a
[MONTH
] > 11
2260 : a
[DATE
] < 1 || a
[DATE
] > daysInMonth(a
[YEAR
], a
[MONTH
])
2267 a
[MILLISECOND
] !== 0))
2269 : a
[MINUTE
] < 0 || a
[MINUTE
] > 59
2271 : a
[SECOND
] < 0 || a
[SECOND
] > 59
2273 : a
[MILLISECOND
] < 0 || a
[MILLISECOND
] > 999
2278 getParsingFlags(m
)._overflowDayOfYear
&&
2279 (overflow
< YEAR
|| overflow
> DATE
)
2283 if (getParsingFlags(m
)._overflowWeeks
&& overflow
=== -1) {
2286 if (getParsingFlags(m
)._overflowWeekday
&& overflow
=== -1) {
2290 getParsingFlags(m
).overflow
= overflow
;
2297 // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
2298 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)?)?$/,
2299 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)?)?$/,
2300 tzRegex
= /Z|[+-]\d\d(?::?\d\d)?/,
2302 ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
2303 ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
2304 ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
2305 ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
2306 ['YYYY-DDD', /\d{4}-\d{3}/],
2307 ['YYYY-MM', /\d{4}-\d\d/, false],
2308 ['YYYYYYMMDD', /[+-]\d{10}/],
2309 ['YYYYMMDD', /\d{8}/],
2310 ['GGGG[W]WWE', /\d{4}W\d{3}/],
2311 ['GGGG[W]WW', /\d{4}W\d{2}/, false],
2312 ['YYYYDDD', /\d{7}/],
2313 ['YYYYMM', /\d{6}/, false],
2314 ['YYYY', /\d{4}/, false],
2316 // iso time formats and regexes
2318 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
2319 ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
2320 ['HH:mm:ss', /\d\d:\d\d:\d\d/],
2321 ['HH:mm', /\d\d:\d\d/],
2322 ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
2323 ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
2324 ['HHmmss', /\d\d\d\d\d\d/],
2325 ['HHmm', /\d\d\d\d/],
2328 aspNetJsonRegex
= /^\/?Date\((-?\d+)/i,
2329 // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
2330 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}))$/,
2344 // date from iso format
2345 function configFromISO(config
) {
2349 match
= extendedIsoRegex
.exec(string
) || basicIsoRegex
.exec(string
),
2356 getParsingFlags(config
).iso
= true;
2358 for (i
= 0, l
= isoDates
.length
; i
< l
; i
++) {
2359 if (isoDates
[i
][1].exec(match
[1])) {
2360 dateFormat
= isoDates
[i
][0];
2361 allowTime
= isoDates
[i
][2] !== false;
2365 if (dateFormat
== null) {
2366 config
._isValid
= false;
2370 for (i
= 0, l
= isoTimes
.length
; i
< l
; i
++) {
2371 if (isoTimes
[i
][1].exec(match
[3])) {
2372 // match[2] should be 'T' or space
2373 timeFormat
= (match
[2] || ' ') + isoTimes
[i
][0];
2377 if (timeFormat
== null) {
2378 config
._isValid
= false;
2382 if (!allowTime
&& timeFormat
!= null) {
2383 config
._isValid
= false;
2387 if (tzRegex
.exec(match
[4])) {
2390 config
._isValid
= false;
2394 config
._f
= dateFormat
+ (timeFormat
|| '') + (tzFormat
|| '');
2395 configFromStringAndFormat(config
);
2397 config
._isValid
= false;
2401 function extractFromRFC2822Strings(
2410 untruncateYear(yearStr
),
2411 defaultLocaleMonthsShort
.indexOf(monthStr
),
2412 parseInt(dayStr
, 10),
2413 parseInt(hourStr
, 10),
2414 parseInt(minuteStr
, 10),
2418 result
.push(parseInt(secondStr
, 10));
2424 function untruncateYear(yearStr
) {
2425 var year
= parseInt(yearStr
, 10);
2428 } else if (year
<= 999) {
2434 function preprocessRFC2822(s
) {
2435 // Remove comments and folding whitespace and replace multiple-spaces with a single space
2437 .replace(/\([^)]*\)|[\n\t]/g, ' ')
2438 .replace(/(\s\s+)/g, ' ')
2439 .replace(/^\s\s*/, '')
2440 .replace(/\s\s*$/, '');
2443 function checkWeekday(weekdayStr
, parsedInput
, config
) {
2445 // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
2446 var weekdayProvided
= defaultLocaleWeekdaysShort
.indexOf(weekdayStr
),
2447 weekdayActual
= new Date(
2452 if (weekdayProvided
!== weekdayActual
) {
2453 getParsingFlags(config
).weekdayMismatch
= true;
2454 config
._isValid
= false;
2461 function calculateOffset(obsOffset
, militaryOffset
, numOffset
) {
2463 return obsOffsets
[obsOffset
];
2464 } else if (militaryOffset
) {
2465 // the only allowed military tz is Z
2468 var hm
= parseInt(numOffset
, 10),
2475 // date and time from ref 2822 format
2476 function configFromRFC2822(config
) {
2477 var match
= rfc2822
.exec(preprocessRFC2822(config
._i
)),
2480 parsedArray
= extractFromRFC2822Strings(
2488 if (!checkWeekday(match
[1], parsedArray
, config
)) {
2492 config
._a
= parsedArray
;
2493 config
._tzm
= calculateOffset(match
[8], match
[9], match
[10]);
2495 config
._d
= createUTCDate
.apply(null, config
._a
);
2496 config
._d
.setUTCMinutes(config
._d
.getUTCMinutes() - config
._tzm
);
2498 getParsingFlags(config
).rfc2822
= true;
2500 config
._isValid
= false;
2504 // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
2505 function configFromString(config
) {
2506 var matched
= aspNetJsonRegex
.exec(config
._i
);
2507 if (matched
!== null) {
2508 config
._d
= new Date(+matched
[1]);
2512 configFromISO(config
);
2513 if (config
._isValid
=== false) {
2514 delete config
._isValid
;
2519 configFromRFC2822(config
);
2520 if (config
._isValid
=== false) {
2521 delete config
._isValid
;
2526 if (config
._strict
) {
2527 config
._isValid
= false;
2529 // Final attempt, use Input Fallback
2530 hooks
.createFromInputFallback(config
);
2534 hooks
.createFromInputFallback
= deprecate(
2535 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
2536 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
2537 'discouraged and will be removed in an upcoming major release. Please refer to ' +
2538 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
2540 config
._d
= new Date(config
._i
+ (config
._useUTC
? ' UTC' : ''));
2544 // Pick the first defined of two or three arguments.
2545 function defaults(a
, b
, c
) {
2555 function currentDateArray(config
) {
2556 // hooks is actually the exported moment object
2557 var nowValue
= new Date(hooks
.now());
2558 if (config
._useUTC
) {
2560 nowValue
.getUTCFullYear(),
2561 nowValue
.getUTCMonth(),
2562 nowValue
.getUTCDate(),
2565 return [nowValue
.getFullYear(), nowValue
.getMonth(), nowValue
.getDate()];
2568 // convert an array to a date.
2569 // the array should mirror the parameters below
2570 // note: all values past the year are optional and will default to the lowest possible value.
2571 // [year, month, day , hour, minute, second, millisecond]
2572 function configFromArray(config
) {
2584 currentDate
= currentDateArray(config
);
2586 //compute day of the year from weeks and weekdays
2587 if (config
._w
&& config
._a
[DATE
] == null && config
._a
[MONTH
] == null) {
2588 dayOfYearFromWeekInfo(config
);
2591 //if the day of the year is set, figure out what it is
2592 if (config
._dayOfYear
!= null) {
2593 yearToUse
= defaults(config
._a
[YEAR
], currentDate
[YEAR
]);
2596 config
._dayOfYear
> daysInYear(yearToUse
) ||
2597 config
._dayOfYear
=== 0
2599 getParsingFlags(config
)._overflowDayOfYear
= true;
2602 date
= createUTCDate(yearToUse
, 0, config
._dayOfYear
);
2603 config
._a
[MONTH
] = date
.getUTCMonth();
2604 config
._a
[DATE
] = date
.getUTCDate();
2607 // Default to current date.
2608 // * if no year, month, day of month are given, default to today
2609 // * if day of month is given, default month and year
2610 // * if month is given, default only year
2611 // * if year is given, don't default anything
2612 for (i
= 0; i
< 3 && config
._a
[i
] == null; ++i
) {
2613 config
._a
[i
] = input
[i
] = currentDate
[i
];
2616 // Zero out whatever was not defaulted, including time
2617 for (; i
< 7; i
++) {
2618 config
._a
[i
] = input
[i
] =
2619 config
._a
[i
] == null ? (i
=== 2 ? 1 : 0) : config
._a
[i
];
2622 // Check for 24:00:00.000
2624 config
._a
[HOUR
] === 24 &&
2625 config
._a
[MINUTE
] === 0 &&
2626 config
._a
[SECOND
] === 0 &&
2627 config
._a
[MILLISECOND
] === 0
2629 config
._nextDay
= true;
2630 config
._a
[HOUR
] = 0;
2633 config
._d
= (config
._useUTC
? createUTCDate
: createDate
).apply(
2637 expectedWeekday
= config
._useUTC
2638 ? config
._d
.getUTCDay()
2639 : config
._d
.getDay();
2641 // Apply timezone offset from input. The actual utcOffset can be changed
2643 if (config
._tzm
!= null) {
2644 config
._d
.setUTCMinutes(config
._d
.getUTCMinutes() - config
._tzm
);
2647 if (config
._nextDay
) {
2648 config
._a
[HOUR
] = 24;
2651 // check for mismatching day of week
2654 typeof config
._w
.d
!== 'undefined' &&
2655 config
._w
.d
!== expectedWeekday
2657 getParsingFlags(config
).weekdayMismatch
= true;
2661 function dayOfYearFromWeekInfo(config
) {
2662 var w
, weekYear
, week
, weekday
, dow
, doy
, temp
, weekdayOverflow
, curWeek
;
2665 if (w
.GG
!= null || w
.W
!= null || w
.E
!= null) {
2669 // TODO: We need to take the current isoWeekYear, but that depends on
2670 // how we interpret now (local, utc, fixed offset). So create
2671 // a now version of current config (take local/utc/offset flags, and
2673 weekYear
= defaults(
2676 weekOfYear(createLocal(), 1, 4).year
2678 week
= defaults(w
.W
, 1);
2679 weekday
= defaults(w
.E
, 1);
2680 if (weekday
< 1 || weekday
> 7) {
2681 weekdayOverflow
= true;
2684 dow
= config
._locale
._week
.dow
;
2685 doy
= config
._locale
._week
.doy
;
2687 curWeek
= weekOfYear(createLocal(), dow
, doy
);
2689 weekYear
= defaults(w
.gg
, config
._a
[YEAR
], curWeek
.year
);
2691 // Default to current week.
2692 week
= defaults(w
.w
, curWeek
.week
);
2695 // weekday -- low day numbers are considered next week
2697 if (weekday
< 0 || weekday
> 6) {
2698 weekdayOverflow
= true;
2700 } else if (w
.e
!= null) {
2701 // local weekday -- counting starts from beginning of week
2702 weekday
= w
.e
+ dow
;
2703 if (w
.e
< 0 || w
.e
> 6) {
2704 weekdayOverflow
= true;
2707 // default to beginning of week
2711 if (week
< 1 || week
> weeksInYear(weekYear
, dow
, doy
)) {
2712 getParsingFlags(config
)._overflowWeeks
= true;
2713 } else if (weekdayOverflow
!= null) {
2714 getParsingFlags(config
)._overflowWeekday
= true;
2716 temp
= dayOfYearFromWeeks(weekYear
, week
, weekday
, dow
, doy
);
2717 config
._a
[YEAR
] = temp
.year
;
2718 config
._dayOfYear
= temp
.dayOfYear
;
2722 // constant that refers to the ISO standard
2723 hooks
.ISO_8601 = function () {};
2725 // constant that refers to the RFC 2822 form
2726 hooks
.RFC_2822 = function () {};
2728 // date from string and format string
2729 function configFromStringAndFormat(config
) {
2730 // TODO: Move this to another part of the creation flow to prevent circular deps
2731 if (config
._f
=== hooks
.ISO_8601
) {
2732 configFromISO(config
);
2735 if (config
._f
=== hooks
.RFC_2822
) {
2736 configFromRFC2822(config
);
2740 getParsingFlags(config
).empty
= true;
2742 // This array is used to make a Date, either with `new Date` or `Date.UTC`
2743 var string
= '' + config
._i
,
2749 stringLength
= string
.length
,
2750 totalParsedInputLength
= 0,
2754 expandFormat(config
._f
, config
._locale
).match(formattingTokens
) || [];
2756 for (i
= 0; i
< tokens
.length
; i
++) {
2758 parsedInput
= (string
.match(getParseRegexForToken(token
, config
)) ||
2761 skipped
= string
.substr(0, string
.indexOf(parsedInput
));
2762 if (skipped
.length
> 0) {
2763 getParsingFlags(config
).unusedInput
.push(skipped
);
2765 string
= string
.slice(
2766 string
.indexOf(parsedInput
) + parsedInput
.length
2768 totalParsedInputLength
+= parsedInput
.length
;
2770 // don't parse if it's not a known token
2771 if (formatTokenFunctions
[token
]) {
2773 getParsingFlags(config
).empty
= false;
2775 getParsingFlags(config
).unusedTokens
.push(token
);
2777 addTimeToArrayFromToken(token
, parsedInput
, config
);
2778 } else if (config
._strict
&& !parsedInput
) {
2779 getParsingFlags(config
).unusedTokens
.push(token
);
2783 // add remaining unparsed input length to the string
2784 getParsingFlags(config
).charsLeftOver
=
2785 stringLength
- totalParsedInputLength
;
2786 if (string
.length
> 0) {
2787 getParsingFlags(config
).unusedInput
.push(string
);
2790 // clear _12h flag if hour is <= 12
2792 config
._a
[HOUR
] <= 12 &&
2793 getParsingFlags(config
).bigHour
=== true &&
2796 getParsingFlags(config
).bigHour
= undefined;
2799 getParsingFlags(config
).parsedDateParts
= config
._a
.slice(0);
2800 getParsingFlags(config
).meridiem
= config
._meridiem
;
2802 config
._a
[HOUR
] = meridiemFixWrap(
2809 era
= getParsingFlags(config
).era
;
2811 config
._a
[YEAR
] = config
._locale
.erasConvertYear(era
, config
._a
[YEAR
]);
2814 configFromArray(config
);
2815 checkOverflow(config
);
2818 function meridiemFixWrap(locale
, hour
, meridiem
) {
2821 if (meridiem
== null) {
2825 if (locale
.meridiemHour
!= null) {
2826 return locale
.meridiemHour(hour
, meridiem
);
2827 } else if (locale
.isPM
!= null) {
2829 isPm
= locale
.isPM(meridiem
);
2830 if (isPm
&& hour
< 12) {
2833 if (!isPm
&& hour
=== 12) {
2838 // this is not supposed to happen
2843 // date from string and array of format strings
2844 function configFromStringAndArray(config
) {
2851 bestFormatIsValid
= false;
2853 if (config
._f
.length
=== 0) {
2854 getParsingFlags(config
).invalidFormat
= true;
2855 config
._d
= new Date(NaN
);
2859 for (i
= 0; i
< config
._f
.length
; i
++) {
2861 validFormatFound
= false;
2862 tempConfig
= copyConfig({}, config
);
2863 if (config
._useUTC
!= null) {
2864 tempConfig
._useUTC
= config
._useUTC
;
2866 tempConfig
._f
= config
._f
[i
];
2867 configFromStringAndFormat(tempConfig
);
2869 if (isValid(tempConfig
)) {
2870 validFormatFound
= true;
2873 // if there is any input that was not parsed add a penalty for that format
2874 currentScore
+= getParsingFlags(tempConfig
).charsLeftOver
;
2877 currentScore
+= getParsingFlags(tempConfig
).unusedTokens
.length
* 10;
2879 getParsingFlags(tempConfig
).score
= currentScore
;
2881 if (!bestFormatIsValid
) {
2883 scoreToBeat
== null ||
2884 currentScore
< scoreToBeat
||
2887 scoreToBeat
= currentScore
;
2888 bestMoment
= tempConfig
;
2889 if (validFormatFound
) {
2890 bestFormatIsValid
= true;
2894 if (currentScore
< scoreToBeat
) {
2895 scoreToBeat
= currentScore
;
2896 bestMoment
= tempConfig
;
2901 extend(config
, bestMoment
|| tempConfig
);
2904 function configFromObject(config
) {
2909 var i
= normalizeObjectUnits(config
._i
),
2910 dayOrDate
= i
.day
=== undefined ? i
.date
: i
.day
;
2912 [i
.year
, i
.month
, dayOrDate
, i
.hour
, i
.minute
, i
.second
, i
.millisecond
],
2914 return obj
&& parseInt(obj
, 10);
2918 configFromArray(config
);
2921 function createFromConfig(config
) {
2922 var res
= new Moment(checkOverflow(prepareConfig(config
)));
2924 // Adding is smart enough around DST
2926 res
._nextDay
= undefined;
2932 function prepareConfig(config
) {
2933 var input
= config
._i
,
2936 config
._locale
= config
._locale
|| getLocale(config
._l
);
2938 if (input
=== null || (format
=== undefined && input
=== '')) {
2939 return createInvalid({ nullInput
: true });
2942 if (typeof input
=== 'string') {
2943 config
._i
= input
= config
._locale
.preparse(input
);
2946 if (isMoment(input
)) {
2947 return new Moment(checkOverflow(input
));
2948 } else if (isDate(input
)) {
2950 } else if (isArray(format
)) {
2951 configFromStringAndArray(config
);
2952 } else if (format
) {
2953 configFromStringAndFormat(config
);
2955 configFromInput(config
);
2958 if (!isValid(config
)) {
2965 function configFromInput(config
) {
2966 var input
= config
._i
;
2967 if (isUndefined(input
)) {
2968 config
._d
= new Date(hooks
.now());
2969 } else if (isDate(input
)) {
2970 config
._d
= new Date(input
.valueOf());
2971 } else if (typeof input
=== 'string') {
2972 configFromString(config
);
2973 } else if (isArray(input
)) {
2974 config
._a
= map(input
.slice(0), function (obj
) {
2975 return parseInt(obj
, 10);
2977 configFromArray(config
);
2978 } else if (isObject(input
)) {
2979 configFromObject(config
);
2980 } else if (isNumber(input
)) {
2981 // from milliseconds
2982 config
._d
= new Date(input
);
2984 hooks
.createFromInputFallback(config
);
2988 function createLocalOrUTC(input
, format
, locale
, strict
, isUTC
) {
2991 if (format
=== true || format
=== false) {
2996 if (locale
=== true || locale
=== false) {
3002 (isObject(input
) && isObjectEmpty(input
)) ||
3003 (isArray(input
) && input
.length
=== 0)
3007 // object construction must be done this way.
3008 // https://github.com/moment/moment/issues/1423
3009 c
._isAMomentObject
= true;
3010 c
._useUTC
= c
._isUTC
= isUTC
;
3016 return createFromConfig(c
);
3019 function createLocal(input
, format
, locale
, strict
) {
3020 return createLocalOrUTC(input
, format
, locale
, strict
, false);
3023 var prototypeMin
= deprecate(
3024 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
3026 var other
= createLocal
.apply(null, arguments
);
3027 if (this.isValid() && other
.isValid()) {
3028 return other
< this ? this : other
;
3030 return createInvalid();
3034 prototypeMax
= deprecate(
3035 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
3037 var other
= createLocal
.apply(null, arguments
);
3038 if (this.isValid() && other
.isValid()) {
3039 return other
> this ? this : other
;
3041 return createInvalid();
3046 // Pick a moment m from moments so that m[fn](other) is true for all
3047 // other. This relies on the function fn to be transitive.
3049 // moments should either be an array of moment objects or an array, whose
3050 // first element is an array of moment objects.
3051 function pickBy(fn
, moments
) {
3053 if (moments
.length
=== 1 && isArray(moments
[0])) {
3054 moments
= moments
[0];
3056 if (!moments
.length
) {
3057 return createLocal();
3060 for (i
= 1; i
< moments
.length
; ++i
) {
3061 if (!moments
[i
].isValid() || moments
[i
][fn
](res
)) {
3068 // TODO: Use [].sort instead?
3070 var args
= [].slice
.call(arguments
, 0);
3072 return pickBy('isBefore', args
);
3076 var args
= [].slice
.call(arguments
, 0);
3078 return pickBy('isAfter', args
);
3081 var now = function () {
3082 return Date
.now
? Date
.now() : +new Date();
3097 function isDurationValid(m
) {
3099 unitHasDecimal
= false,
3103 hasOwnProp(m
, key
) &&
3105 indexOf
.call(ordering
, key
) !== -1 &&
3106 (m
[key
] == null || !isNaN(m
[key
]))
3113 for (i
= 0; i
< ordering
.length
; ++i
) {
3114 if (m
[ordering
[i
]]) {
3115 if (unitHasDecimal
) {
3116 return false; // only allow non-integers for smallest unit
3118 if (parseFloat(m
[ordering
[i
]]) !== toInt(m
[ordering
[i
]])) {
3119 unitHasDecimal
= true;
3127 function isValid
$1() {
3128 return this._isValid
;
3131 function createInvalid
$1() {
3132 return createDuration(NaN
);
3135 function Duration(duration
) {
3136 var normalizedInput
= normalizeObjectUnits(duration
),
3137 years
= normalizedInput
.year
|| 0,
3138 quarters
= normalizedInput
.quarter
|| 0,
3139 months
= normalizedInput
.month
|| 0,
3140 weeks
= normalizedInput
.week
|| normalizedInput
.isoWeek
|| 0,
3141 days
= normalizedInput
.day
|| 0,
3142 hours
= normalizedInput
.hour
|| 0,
3143 minutes
= normalizedInput
.minute
|| 0,
3144 seconds
= normalizedInput
.second
|| 0,
3145 milliseconds
= normalizedInput
.millisecond
|| 0;
3147 this._isValid
= isDurationValid(normalizedInput
);
3149 // representation for dateAddRemove
3150 this._milliseconds
=
3152 seconds
* 1e3
+ // 1000
3153 minutes
* 6e4
+ // 1000 * 60
3154 hours
* 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
3155 // Because of dateAddRemove treats 24 hours as different from a
3156 // day when working around DST, we need to store them separately
3157 this._days
= +days
+ weeks
* 7;
3158 // It is impossible to translate months into days without knowing
3159 // which months you are are talking about, so we have to store
3161 this._months
= +months
+ quarters
* 3 + years
* 12;
3165 this._locale
= getLocale();
3170 function isDuration(obj
) {
3171 return obj
instanceof Duration
;
3174 function absRound(number
) {
3176 return Math
.round(-1 * number
) * -1;
3178 return Math
.round(number
);
3182 // compare two arrays, return the number of differences
3183 function compareArrays(array1
, array2
, dontConvert
) {
3184 var len
= Math
.min(array1
.length
, array2
.length
),
3185 lengthDiff
= Math
.abs(array1
.length
- array2
.length
),
3188 for (i
= 0; i
< len
; i
++) {
3190 (dontConvert
&& array1
[i
] !== array2
[i
]) ||
3191 (!dontConvert
&& toInt(array1
[i
]) !== toInt(array2
[i
]))
3196 return diffs
+ lengthDiff
;
3201 function offset(token
, separator
) {
3202 addFormatToken(token
, 0, 0, function () {
3203 var offset
= this.utcOffset(),
3211 zeroFill(~~(offset
/ 60), 2) +
3213 zeroFill(~~offset
% 60, 2)
3223 addRegexToken('Z', matchShortOffset
);
3224 addRegexToken('ZZ', matchShortOffset
);
3225 addParseToken(['Z', 'ZZ'], function (input
, array
, config
) {
3226 config
._useUTC
= true;
3227 config
._tzm
= offsetFromString(matchShortOffset
, input
);
3233 // '+10:00' > ['10', '00']
3234 // '-1530' > ['-15', '30']
3235 var chunkOffset
= /([\+\-]|\d\d)/gi;
3237 function offsetFromString(matcher
, string
) {
3238 var matches
= (string
|| '').match(matcher
),
3243 if (matches
=== null) {
3247 chunk
= matches
[matches
.length
- 1] || [];
3248 parts
= (chunk
+ '').match(chunkOffset
) || ['-', 0, 0];
3249 minutes
= +(parts
[1] * 60) + toInt(parts
[2]);
3251 return minutes
=== 0 ? 0 : parts
[0] === '+' ? minutes
: -minutes
;
3254 // Return a moment from input, that is local/utc/zone equivalent to model.
3255 function cloneWithOffset(input
, model
) {
3258 res
= model
.clone();
3260 (isMoment(input
) || isDate(input
)
3262 : createLocal(input
).valueOf()) - res
.valueOf();
3263 // Use low-level api, because this fn is low-level api.
3264 res
._d
.setTime(res
._d
.valueOf() + diff
);
3265 hooks
.updateOffset(res
, false);
3268 return createLocal(input
).local();
3272 function getDateOffset(m
) {
3273 // On Firefox.24 Date#getTimezoneOffset returns a floating point.
3274 // https://github.com/moment/moment/pull/1871
3275 return -Math
.round(m
._d
.getTimezoneOffset());
3280 // This function will be called whenever a moment is mutated.
3281 // It is intended to keep the offset in sync with the timezone.
3282 hooks
.updateOffset = function () {};
3286 // keepLocalTime = true means only change the timezone, without
3287 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
3288 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
3289 // +0200, so we adjust the time as needed, to be valid.
3291 // Keeping the time actually adds/subtracts (one hour)
3292 // from the actual represented time. That is why we call updateOffset
3293 // a second time. In case it wants us to change the offset again
3294 // _changeInProgress == true case, then we have to adjust, because
3295 // there is no such time in the given timezone.
3296 function getSetOffset(input
, keepLocalTime
, keepMinutes
) {
3297 var offset
= this._offset
|| 0,
3299 if (!this.isValid()) {
3300 return input
!= null ? this : NaN
;
3302 if (input
!= null) {
3303 if (typeof input
=== 'string') {
3304 input
= offsetFromString(matchShortOffset
, input
);
3305 if (input
=== null) {
3308 } else if (Math
.abs(input
) < 16 && !keepMinutes
) {
3311 if (!this._isUTC
&& keepLocalTime
) {
3312 localAdjust
= getDateOffset(this);
3314 this._offset
= input
;
3316 if (localAdjust
!= null) {
3317 this.add(localAdjust
, 'm');
3319 if (offset
!== input
) {
3320 if (!keepLocalTime
|| this._changeInProgress
) {
3323 createDuration(input
- offset
, 'm'),
3327 } else if (!this._changeInProgress
) {
3328 this._changeInProgress
= true;
3329 hooks
.updateOffset(this, true);
3330 this._changeInProgress
= null;
3335 return this._isUTC
? offset
: getDateOffset(this);
3339 function getSetZone(input
, keepLocalTime
) {
3340 if (input
!= null) {
3341 if (typeof input
!== 'string') {
3345 this.utcOffset(input
, keepLocalTime
);
3349 return -this.utcOffset();
3353 function setOffsetToUTC(keepLocalTime
) {
3354 return this.utcOffset(0, keepLocalTime
);
3357 function setOffsetToLocal(keepLocalTime
) {
3359 this.utcOffset(0, keepLocalTime
);
3360 this._isUTC
= false;
3362 if (keepLocalTime
) {
3363 this.subtract(getDateOffset(this), 'm');
3369 function setOffsetToParsedOffset() {
3370 if (this._tzm
!= null) {
3371 this.utcOffset(this._tzm
, false, true);
3372 } else if (typeof this._i
=== 'string') {
3373 var tZone
= offsetFromString(matchOffset
, this._i
);
3374 if (tZone
!= null) {
3375 this.utcOffset(tZone
);
3377 this.utcOffset(0, true);
3383 function hasAlignedHourOffset(input
) {
3384 if (!this.isValid()) {
3387 input
= input
? createLocal(input
).utcOffset() : 0;
3389 return (this.utcOffset() - input
) % 60 === 0;
3392 function isDaylightSavingTime() {
3394 this.utcOffset() > this.clone().month(0).utcOffset() ||
3395 this.utcOffset() > this.clone().month(5).utcOffset()
3399 function isDaylightSavingTimeShifted() {
3400 if (!isUndefined(this._isDSTShifted
)) {
3401 return this._isDSTShifted
;
3407 copyConfig(c
, this);
3408 c
= prepareConfig(c
);
3411 other
= c
._isUTC
? createUTC(c
._a
) : createLocal(c
._a
);
3412 this._isDSTShifted
=
3413 this.isValid() && compareArrays(c
._a
, other
.toArray()) > 0;
3415 this._isDSTShifted
= false;
3418 return this._isDSTShifted
;
3421 function isLocal() {
3422 return this.isValid() ? !this._isUTC
: false;
3425 function isUtcOffset() {
3426 return this.isValid() ? this._isUTC
: false;
3430 return this.isValid() ? this._isUTC
&& this._offset
=== 0 : false;
3433 // ASP.NET json date format regex
3434 var aspNetRegex
= /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
3435 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
3436 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
3437 // and further modified to allow for strings containing both week and day
3438 isoRegex
= /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
3440 function createDuration(input
, key
) {
3441 var duration
= input
,
3442 // matching against regexp is expensive, do it on demand
3448 if (isDuration(input
)) {
3450 ms
: input
._milliseconds
,
3454 } else if (isNumber(input
) || !isNaN(+input
)) {
3457 duration
[key
] = +input
;
3459 duration
.milliseconds
= +input
;
3461 } else if ((match
= aspNetRegex
.exec(input
))) {
3462 sign
= match
[1] === '-' ? -1 : 1;
3465 d
: toInt(match
[DATE
]) * sign
,
3466 h
: toInt(match
[HOUR
]) * sign
,
3467 m
: toInt(match
[MINUTE
]) * sign
,
3468 s
: toInt(match
[SECOND
]) * sign
,
3469 ms
: toInt(absRound(match
[MILLISECOND
] * 1000)) * sign
, // the millisecond decimal point is included in the match
3471 } else if ((match
= isoRegex
.exec(input
))) {
3472 sign
= match
[1] === '-' ? -1 : 1;
3474 y
: parseIso(match
[2], sign
),
3475 M
: parseIso(match
[3], sign
),
3476 w
: parseIso(match
[4], sign
),
3477 d
: parseIso(match
[5], sign
),
3478 h
: parseIso(match
[6], sign
),
3479 m
: parseIso(match
[7], sign
),
3480 s
: parseIso(match
[8], sign
),
3482 } else if (duration
== null) {
3483 // checks for null or undefined
3486 typeof duration
=== 'object' &&
3487 ('from' in duration
|| 'to' in duration
)
3489 diffRes
= momentsDifference(
3490 createLocal(duration
.from),
3491 createLocal(duration
.to
)
3495 duration
.ms
= diffRes
.milliseconds
;
3496 duration
.M
= diffRes
.months
;
3499 ret
= new Duration(duration
);
3501 if (isDuration(input
) && hasOwnProp(input
, '_locale')) {
3502 ret
._locale
= input
._locale
;
3505 if (isDuration(input
) && hasOwnProp(input
, '_isValid')) {
3506 ret
._isValid
= input
._isValid
;
3512 createDuration
.fn
= Duration
.prototype;
3513 createDuration
.invalid
= createInvalid
$1;
3515 function parseIso(inp
, sign
) {
3516 // We'd normally use ~~inp for this, but unfortunately it also
3517 // converts floats to ints.
3518 // inp may be undefined, so careful calling replace on it.
3519 var res
= inp
&& parseFloat(inp
.replace(',', '.'));
3520 // apply sign while we're at it
3521 return (isNaN(res
) ? 0 : res
) * sign
;
3524 function positiveMomentsDifference(base
, other
) {
3528 other
.month() - base
.month() + (other
.year() - base
.year()) * 12;
3529 if (base
.clone().add(res
.months
, 'M').isAfter(other
)) {
3533 res
.milliseconds
= +other
- +base
.clone().add(res
.months
, 'M');
3538 function momentsDifference(base
, other
) {
3540 if (!(base
.isValid() && other
.isValid())) {
3541 return { milliseconds
: 0, months
: 0 };
3544 other
= cloneWithOffset(other
, base
);
3545 if (base
.isBefore(other
)) {
3546 res
= positiveMomentsDifference(base
, other
);
3548 res
= positiveMomentsDifference(other
, base
);
3549 res
.milliseconds
= -res
.milliseconds
;
3550 res
.months
= -res
.months
;
3556 // TODO: remove 'name' arg after deprecation is removed
3557 function createAdder(direction
, name
) {
3558 return function (val
, period
) {
3560 //invert the arguments, but complain about it
3561 if (period
!== null && !isNaN(+period
)) {
3566 '(period, number) is deprecated. Please use moment().' +
3568 '(number, period). ' +
3569 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
3576 dur
= createDuration(val
, period
);
3577 addSubtract(this, dur
, direction
);
3582 function addSubtract(mom
, duration
, isAdding
, updateOffset
) {
3583 var milliseconds
= duration
._milliseconds
,
3584 days
= absRound(duration
._days
),
3585 months
= absRound(duration
._months
);
3587 if (!mom
.isValid()) {
3592 updateOffset
= updateOffset
== null ? true : updateOffset
;
3595 setMonth(mom
, get(mom
, 'Month') + months
* isAdding
);
3598 set$1(mom
, 'Date', get(mom
, 'Date') + days
* isAdding
);
3601 mom
._d
.setTime(mom
._d
.valueOf() + milliseconds
* isAdding
);
3604 hooks
.updateOffset(mom
, days
|| months
);
3608 var add
= createAdder(1, 'add'),
3609 subtract
= createAdder(-1, 'subtract');
3611 function isString(input
) {
3612 return typeof input
=== 'string' || input
instanceof String
;
3615 // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
3616 function isMomentInput(input
) {
3622 isNumberOrStringArray(input
) ||
3623 isMomentInputObject(input
) ||
3629 function isMomentInputObject(input
) {
3630 var objectTest
= isObject(input
) && !isObjectEmpty(input
),
3631 propertyTest
= false,
3661 for (i
= 0; i
< properties
.length
; i
+= 1) {
3662 property
= properties
[i
];
3663 propertyTest
= propertyTest
|| hasOwnProp(input
, property
);
3666 return objectTest
&& propertyTest
;
3669 function isNumberOrStringArray(input
) {
3670 var arrayTest
= isArray(input
),
3671 dataTypeTest
= false;
3674 input
.filter(function (item
) {
3675 return !isNumber(item
) && isString(input
);
3678 return arrayTest
&& dataTypeTest
;
3681 function isCalendarSpec(input
) {
3682 var objectTest
= isObject(input
) && !isObjectEmpty(input
),
3683 propertyTest
= false,
3695 for (i
= 0; i
< properties
.length
; i
+= 1) {
3696 property
= properties
[i
];
3697 propertyTest
= propertyTest
|| hasOwnProp(input
, property
);
3700 return objectTest
&& propertyTest
;
3703 function getCalendarFormat(myMoment
, now
) {
3704 var diff
= myMoment
.diff(now
, 'days', true);
3720 function calendar
$1(time
, formats
) {
3721 // Support for single parameter, formats only overload to the calendar function
3722 if (arguments
.length
=== 1) {
3723 if (!arguments
[0]) {
3725 formats
= undefined;
3726 } else if (isMomentInput(arguments
[0])) {
3727 time
= arguments
[0];
3728 formats
= undefined;
3729 } else if (isCalendarSpec(arguments
[0])) {
3730 formats
= arguments
[0];
3734 // We want to compare the start of today, vs this.
3735 // Getting start-of-today depends on whether we're local/utc/offset or not.
3736 var now
= time
|| createLocal(),
3737 sod
= cloneWithOffset(now
, this).startOf('day'),
3738 format
= hooks
.calendarFormat(this, sod
) || 'sameElse',
3741 (isFunction(formats
[format
])
3742 ? formats
[format
].call(this, now
)
3746 output
|| this.localeData().calendar(format
, this, createLocal(now
))
3751 return new Moment(this);
3754 function isAfter(input
, units
) {
3755 var localInput
= isMoment(input
) ? input
: createLocal(input
);
3756 if (!(this.isValid() && localInput
.isValid())) {
3759 units
= normalizeUnits(units
) || 'millisecond';
3760 if (units
=== 'millisecond') {
3761 return this.valueOf() > localInput
.valueOf();
3763 return localInput
.valueOf() < this.clone().startOf(units
).valueOf();
3767 function isBefore(input
, units
) {
3768 var localInput
= isMoment(input
) ? input
: createLocal(input
);
3769 if (!(this.isValid() && localInput
.isValid())) {
3772 units
= normalizeUnits(units
) || 'millisecond';
3773 if (units
=== 'millisecond') {
3774 return this.valueOf() < localInput
.valueOf();
3776 return this.clone().endOf(units
).valueOf() < localInput
.valueOf();
3780 function isBetween(from, to
, units
, inclusivity
) {
3781 var localFrom
= isMoment(from) ? from : createLocal(from),
3782 localTo
= isMoment(to
) ? to
: createLocal(to
);
3783 if (!(this.isValid() && localFrom
.isValid() && localTo
.isValid())) {
3786 inclusivity
= inclusivity
|| '()';
3788 (inclusivity
[0] === '('
3789 ? this.isAfter(localFrom
, units
)
3790 : !this.isBefore(localFrom
, units
)) &&
3791 (inclusivity
[1] === ')'
3792 ? this.isBefore(localTo
, units
)
3793 : !this.isAfter(localTo
, units
))
3797 function isSame(input
, units
) {
3798 var localInput
= isMoment(input
) ? input
: createLocal(input
),
3800 if (!(this.isValid() && localInput
.isValid())) {
3803 units
= normalizeUnits(units
) || 'millisecond';
3804 if (units
=== 'millisecond') {
3805 return this.valueOf() === localInput
.valueOf();
3807 inputMs
= localInput
.valueOf();
3809 this.clone().startOf(units
).valueOf() <= inputMs
&&
3810 inputMs
<= this.clone().endOf(units
).valueOf()
3815 function isSameOrAfter(input
, units
) {
3816 return this.isSame(input
, units
) || this.isAfter(input
, units
);
3819 function isSameOrBefore(input
, units
) {
3820 return this.isSame(input
, units
) || this.isBefore(input
, units
);
3823 function diff(input
, units
, asFloat
) {
3824 var that
, zoneDelta
, output
;
3826 if (!this.isValid()) {
3830 that
= cloneWithOffset(input
, this);
3832 if (!that
.isValid()) {
3836 zoneDelta
= (that
.utcOffset() - this.utcOffset()) * 6e4
;
3838 units
= normalizeUnits(units
);
3842 output
= monthDiff(this, that
) / 12;
3845 output
= monthDiff(this, that
);
3848 output
= monthDiff(this, that
) / 3;
3851 output
= (this - that
) / 1e3
;
3854 output
= (this - that
) / 6e4
;
3857 output
= (this - that
) / 36e5
;
3858 break; // 1000 * 60 * 60
3860 output
= (this - that
- zoneDelta
) / 864e5
;
3861 break; // 1000 * 60 * 60 * 24, negate dst
3863 output
= (this - that
- zoneDelta
) / 6048e5
;
3864 break; // 1000 * 60 * 60 * 24 * 7, negate dst
3866 output
= this - that
;
3869 return asFloat
? output
: absFloor(output
);
3872 function monthDiff(a
, b
) {
3873 if (a
.date() < b
.date()) {
3874 // end-of-month calculations work correct when the start month has more
3875 // days than the end month.
3876 return -monthDiff(b
, a
);
3878 // difference in months
3879 var wholeMonthDiff
= (b
.year() - a
.year()) * 12 + (b
.month() - a
.month()),
3880 // b is in (anchor - 1 month, anchor + 1 month)
3881 anchor
= a
.clone().add(wholeMonthDiff
, 'months'),
3885 if (b
- anchor
< 0) {
3886 anchor2
= a
.clone().add(wholeMonthDiff
- 1, 'months');
3887 // linear across the month
3888 adjust
= (b
- anchor
) / (anchor
- anchor2
);
3890 anchor2
= a
.clone().add(wholeMonthDiff
+ 1, 'months');
3891 // linear across the month
3892 adjust
= (b
- anchor
) / (anchor2
- anchor
);
3895 //check for negative zero, return zero if negative zero
3896 return -(wholeMonthDiff
+ adjust
) || 0;
3899 hooks
.defaultFormat
= 'YYYY-MM-DDTHH:mm:ssZ';
3900 hooks
.defaultFormatUtc
= 'YYYY-MM-DDTHH:mm:ss[Z]';
3902 function toString() {
3903 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
3906 function toISOString(keepOffset
) {
3907 if (!this.isValid()) {
3910 var utc
= keepOffset
!== true,
3911 m
= utc
? this.clone().utc() : this;
3912 if (m
.year() < 0 || m
.year() > 9999) {
3913 return formatMoment(
3916 ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
3917 : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
3920 if (isFunction(Date
.prototype.toISOString
)) {
3921 // native implementation is ~50x faster, use it when we can
3923 return this.toDate().toISOString();
3925 return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
3927 .replace('Z', formatMoment(m
, 'Z'));
3930 return formatMoment(
3932 utc
? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
3937 * Return a human readable representation of a moment that can
3938 * also be evaluated to get a new moment which is the same
3940 * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
3942 function inspect() {
3943 if (!this.isValid()) {
3944 return 'moment.invalid(/* ' + this._i
+ ' */)';
3946 var func
= 'moment',
3952 if (!this.isLocal()) {
3953 func
= this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
3956 prefix
= '[' + func
+ '("]';
3957 year
= 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
3958 datetime
= '-MM-DD[T]HH:mm:ss.SSS';
3959 suffix
= zone
+ '[")]';
3961 return this.format(prefix
+ year
+ datetime
+ suffix
);
3964 function format(inputString
) {
3966 inputString
= this.isUtc()
3967 ? hooks
.defaultFormatUtc
3968 : hooks
.defaultFormat
;
3970 var output
= formatMoment(this, inputString
);
3971 return this.localeData().postformat(output
);
3974 function from(time
, withoutSuffix
) {
3977 ((isMoment(time
) && time
.isValid()) || createLocal(time
).isValid())
3979 return createDuration({ to
: this, from: time
})
3980 .locale(this.locale())
3981 .humanize(!withoutSuffix
);
3983 return this.localeData().invalidDate();
3987 function fromNow(withoutSuffix
) {
3988 return this.from(createLocal(), withoutSuffix
);
3991 function to(time
, withoutSuffix
) {
3994 ((isMoment(time
) && time
.isValid()) || createLocal(time
).isValid())
3996 return createDuration({ from: this, to
: time
})
3997 .locale(this.locale())
3998 .humanize(!withoutSuffix
);
4000 return this.localeData().invalidDate();
4004 function toNow(withoutSuffix
) {
4005 return this.to(createLocal(), withoutSuffix
);
4008 // If passed a locale key, it will set the locale for this
4009 // instance. Otherwise, it will return the locale configuration
4010 // variables for this instance.
4011 function locale(key
) {
4014 if (key
=== undefined) {
4015 return this._locale
._abbr
;
4017 newLocaleData
= getLocale(key
);
4018 if (newLocaleData
!= null) {
4019 this._locale
= newLocaleData
;
4025 var lang
= deprecate(
4026 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
4028 if (key
=== undefined) {
4029 return this.localeData();
4031 return this.locale(key
);
4036 function localeData() {
4037 return this._locale
;
4040 var MS_PER_SECOND
= 1000,
4041 MS_PER_MINUTE
= 60 * MS_PER_SECOND
,
4042 MS_PER_HOUR
= 60 * MS_PER_MINUTE
,
4043 MS_PER_400_YEARS
= (365 * 400 + 97) * 24 * MS_PER_HOUR
;
4045 // actual modulo - handles negative numbers (for dates before 1970):
4046 function mod
$1(dividend
, divisor
) {
4047 return ((dividend
% divisor
) + divisor
) % divisor
;
4050 function localStartOfDate(y
, m
, d
) {
4051 // the date constructor remaps years 0-99 to 1900-1999
4052 if (y
< 100 && y
>= 0) {
4053 // preserve leap years using a full 400 year cycle, then reset
4054 return new Date(y
+ 400, m
, d
) - MS_PER_400_YEARS
;
4056 return new Date(y
, m
, d
).valueOf();
4060 function utcStartOfDate(y
, m
, d
) {
4061 // Date.UTC remaps years 0-99 to 1900-1999
4062 if (y
< 100 && y
>= 0) {
4063 // preserve leap years using a full 400 year cycle, then reset
4064 return Date
.UTC(y
+ 400, m
, d
) - MS_PER_400_YEARS
;
4066 return Date
.UTC(y
, m
, d
);
4070 function startOf(units
) {
4071 var time
, startOfDate
;
4072 units
= normalizeUnits(units
);
4073 if (units
=== undefined || units
=== 'millisecond' || !this.isValid()) {
4077 startOfDate
= this._isUTC
? utcStartOfDate
: localStartOfDate
;
4081 time
= startOfDate(this.year(), 0, 1);
4086 this.month() - (this.month() % 3),
4091 time
= startOfDate(this.year(), this.month(), 1);
4097 this.date() - this.weekday()
4104 this.date() - (this.isoWeekday() - 1)
4109 time
= startOfDate(this.year(), this.month(), this.date());
4112 time
= this._d
.valueOf();
4114 time
+ (this._isUTC
? 0 : this.utcOffset() * MS_PER_MINUTE
),
4119 time
= this._d
.valueOf();
4120 time
-= mod
$1(time
, MS_PER_MINUTE
);
4123 time
= this._d
.valueOf();
4124 time
-= mod
$1(time
, MS_PER_SECOND
);
4128 this._d
.setTime(time
);
4129 hooks
.updateOffset(this, true);
4133 function endOf(units
) {
4134 var time
, startOfDate
;
4135 units
= normalizeUnits(units
);
4136 if (units
=== undefined || units
=== 'millisecond' || !this.isValid()) {
4140 startOfDate
= this._isUTC
? utcStartOfDate
: localStartOfDate
;
4144 time
= startOfDate(this.year() + 1, 0, 1) - 1;
4150 this.month() - (this.month() % 3) + 3,
4155 time
= startOfDate(this.year(), this.month() + 1, 1) - 1;
4162 this.date() - this.weekday() + 7
4170 this.date() - (this.isoWeekday() - 1) + 7
4175 time
= startOfDate(this.year(), this.month(), this.date() + 1) - 1;
4178 time
= this._d
.valueOf();
4182 time
+ (this._isUTC
? 0 : this.utcOffset() * MS_PER_MINUTE
),
4188 time
= this._d
.valueOf();
4189 time
+= MS_PER_MINUTE
- mod
$1(time
, MS_PER_MINUTE
) - 1;
4192 time
= this._d
.valueOf();
4193 time
+= MS_PER_SECOND
- mod
$1(time
, MS_PER_SECOND
) - 1;
4197 this._d
.setTime(time
);
4198 hooks
.updateOffset(this, true);
4202 function valueOf() {
4203 return this._d
.valueOf() - (this._offset
|| 0) * 60000;
4207 return Math
.floor(this.valueOf() / 1000);
4211 return new Date(this.valueOf());
4214 function toArray() {
4227 function toObject() {
4234 minutes
: m
.minutes(),
4235 seconds
: m
.seconds(),
4236 milliseconds
: m
.milliseconds(),
4241 // new Date(NaN).toJSON() === null
4242 return this.isValid() ? this.toISOString() : null;
4245 function isValid
$2() {
4246 return isValid(this);
4249 function parsingFlags() {
4250 return extend({}, getParsingFlags(this));
4253 function invalidAt() {
4254 return getParsingFlags(this).overflow
;
4257 function creationData() {
4261 locale
: this._locale
,
4263 strict
: this._strict
,
4267 addFormatToken('N', 0, 0, 'eraAbbr');
4268 addFormatToken('NN', 0, 0, 'eraAbbr');
4269 addFormatToken('NNN', 0, 0, 'eraAbbr');
4270 addFormatToken('NNNN', 0, 0, 'eraName');
4271 addFormatToken('NNNNN', 0, 0, 'eraNarrow');
4273 addFormatToken('y', ['y', 1], 'yo', 'eraYear');
4274 addFormatToken('y', ['yy', 2], 0, 'eraYear');
4275 addFormatToken('y', ['yyy', 3], 0, 'eraYear');
4276 addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
4278 addRegexToken('N', matchEraAbbr
);
4279 addRegexToken('NN', matchEraAbbr
);
4280 addRegexToken('NNN', matchEraAbbr
);
4281 addRegexToken('NNNN', matchEraName
);
4282 addRegexToken('NNNNN', matchEraNarrow
);
4284 addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
4290 var era
= config
._locale
.erasParse(input
, token
, config
._strict
);
4292 getParsingFlags(config
).era
= era
;
4294 getParsingFlags(config
).invalidEra
= input
;
4298 addRegexToken('y', matchUnsigned
);
4299 addRegexToken('yy', matchUnsigned
);
4300 addRegexToken('yyy', matchUnsigned
);
4301 addRegexToken('yyyy', matchUnsigned
);
4302 addRegexToken('yo', matchEraYearOrdinal
);
4304 addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR
);
4305 addParseToken(['yo'], function (input
, array
, config
, token
) {
4307 if (config
._locale
._eraYearOrdinalRegex
) {
4308 match
= input
.match(config
._locale
._eraYearOrdinalRegex
);
4311 if (config
._locale
.eraYearOrdinalParse
) {
4312 array
[YEAR
] = config
._locale
.eraYearOrdinalParse(input
, match
);
4314 array
[YEAR
] = parseInt(input
, 10);
4318 function localeEras(m
, format
) {
4322 eras
= this._eras
|| getLocale('en')._eras
;
4323 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4324 switch (typeof eras
[i
].since
) {
4327 date
= hooks(eras
[i
].since
).startOf('day');
4328 eras
[i
].since
= date
.valueOf();
4332 switch (typeof eras
[i
].until
) {
4334 eras
[i
].until
= +Infinity
;
4338 date
= hooks(eras
[i
].until
).startOf('day').valueOf();
4339 eras
[i
].until
= date
.valueOf();
4346 function localeErasParse(eraName
, format
, strict
) {
4353 eraName
= eraName
.toUpperCase();
4355 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4356 name
= eras
[i
].name
.toUpperCase();
4357 abbr
= eras
[i
].abbr
.toUpperCase();
4358 narrow
= eras
[i
].narrow
.toUpperCase();
4365 if (abbr
=== eraName
) {
4371 if (name
=== eraName
) {
4377 if (narrow
=== eraName
) {
4382 } else if ([name
, abbr
, narrow
].indexOf(eraName
) >= 0) {
4388 function localeErasConvertYear(era
, year
) {
4389 var dir
= era
.since
<= era
.until
? +1 : -1;
4390 if (year
=== undefined) {
4391 return hooks(era
.since
).year();
4393 return hooks(era
.since
).year() + (year
- era
.offset
) * dir
;
4397 function getEraName() {
4401 eras
= this.localeData().eras();
4402 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4404 val
= this.clone().startOf('day').valueOf();
4406 if (eras
[i
].since
<= val
&& val
<= eras
[i
].until
) {
4407 return eras
[i
].name
;
4409 if (eras
[i
].until
<= val
&& val
<= eras
[i
].since
) {
4410 return eras
[i
].name
;
4417 function getEraNarrow() {
4421 eras
= this.localeData().eras();
4422 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4424 val
= this.clone().startOf('day').valueOf();
4426 if (eras
[i
].since
<= val
&& val
<= eras
[i
].until
) {
4427 return eras
[i
].narrow
;
4429 if (eras
[i
].until
<= val
&& val
<= eras
[i
].since
) {
4430 return eras
[i
].narrow
;
4437 function getEraAbbr() {
4441 eras
= this.localeData().eras();
4442 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4444 val
= this.clone().startOf('day').valueOf();
4446 if (eras
[i
].since
<= val
&& val
<= eras
[i
].until
) {
4447 return eras
[i
].abbr
;
4449 if (eras
[i
].until
<= val
&& val
<= eras
[i
].since
) {
4450 return eras
[i
].abbr
;
4457 function getEraYear() {
4462 eras
= this.localeData().eras();
4463 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4464 dir
= eras
[i
].since
<= eras
[i
].until
? +1 : -1;
4467 val
= this.clone().startOf('day').valueOf();
4470 (eras
[i
].since
<= val
&& val
<= eras
[i
].until
) ||
4471 (eras
[i
].until
<= val
&& val
<= eras
[i
].since
)
4474 (this.year() - hooks(eras
[i
].since
).year()) * dir
+
4483 function erasNameRegex(isStrict
) {
4484 if (!hasOwnProp(this, '_erasNameRegex')) {
4485 computeErasParse
.call(this);
4487 return isStrict
? this._erasNameRegex
: this._erasRegex
;
4490 function erasAbbrRegex(isStrict
) {
4491 if (!hasOwnProp(this, '_erasAbbrRegex')) {
4492 computeErasParse
.call(this);
4494 return isStrict
? this._erasAbbrRegex
: this._erasRegex
;
4497 function erasNarrowRegex(isStrict
) {
4498 if (!hasOwnProp(this, '_erasNarrowRegex')) {
4499 computeErasParse
.call(this);
4501 return isStrict
? this._erasNarrowRegex
: this._erasRegex
;
4504 function matchEraAbbr(isStrict
, locale
) {
4505 return locale
.erasAbbrRegex(isStrict
);
4508 function matchEraName(isStrict
, locale
) {
4509 return locale
.erasNameRegex(isStrict
);
4512 function matchEraNarrow(isStrict
, locale
) {
4513 return locale
.erasNarrowRegex(isStrict
);
4516 function matchEraYearOrdinal(isStrict
, locale
) {
4517 return locale
._eraYearOrdinalRegex
|| matchUnsigned
;
4520 function computeErasParse() {
4521 var abbrPieces
= [],
4529 for (i
= 0, l
= eras
.length
; i
< l
; ++i
) {
4530 namePieces
.push(regexEscape(eras
[i
].name
));
4531 abbrPieces
.push(regexEscape(eras
[i
].abbr
));
4532 narrowPieces
.push(regexEscape(eras
[i
].narrow
));
4534 mixedPieces
.push(regexEscape(eras
[i
].name
));
4535 mixedPieces
.push(regexEscape(eras
[i
].abbr
));
4536 mixedPieces
.push(regexEscape(eras
[i
].narrow
));
4539 this._erasRegex
= new RegExp('^(' + mixedPieces
.join('|') + ')', 'i');
4540 this._erasNameRegex
= new RegExp('^(' + namePieces
.join('|') + ')', 'i');
4541 this._erasAbbrRegex
= new RegExp('^(' + abbrPieces
.join('|') + ')', 'i');
4542 this._erasNarrowRegex
= new RegExp(
4543 '^(' + narrowPieces
.join('|') + ')',
4550 addFormatToken(0, ['gg', 2], 0, function () {
4551 return this.weekYear() % 100;
4554 addFormatToken(0, ['GG', 2], 0, function () {
4555 return this.isoWeekYear() % 100;
4558 function addWeekYearFormatToken(token
, getter
) {
4559 addFormatToken(0, [token
, token
.length
], 0, getter
);
4562 addWeekYearFormatToken('gggg', 'weekYear');
4563 addWeekYearFormatToken('ggggg', 'weekYear');
4564 addWeekYearFormatToken('GGGG', 'isoWeekYear');
4565 addWeekYearFormatToken('GGGGG', 'isoWeekYear');
4569 addUnitAlias('weekYear', 'gg');
4570 addUnitAlias('isoWeekYear', 'GG');
4574 addUnitPriority('weekYear', 1);
4575 addUnitPriority('isoWeekYear', 1);
4579 addRegexToken('G', matchSigned
);
4580 addRegexToken('g', matchSigned
);
4581 addRegexToken('GG', match1to2
, match2
);
4582 addRegexToken('gg', match1to2
, match2
);
4583 addRegexToken('GGGG', match1to4
, match4
);
4584 addRegexToken('gggg', match1to4
, match4
);
4585 addRegexToken('GGGGG', match1to6
, match6
);
4586 addRegexToken('ggggg', match1to6
, match6
);
4588 addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (
4594 week
[token
.substr(0, 2)] = toInt(input
);
4597 addWeekParseToken(['gg', 'GG'], function (input
, week
, config
, token
) {
4598 week
[token
] = hooks
.parseTwoDigitYear(input
);
4603 function getSetWeekYear(input
) {
4604 return getSetWeekYearHelper
.call(
4609 this.localeData()._week
.dow
,
4610 this.localeData()._week
.doy
4614 function getSetISOWeekYear(input
) {
4615 return getSetWeekYearHelper
.call(
4625 function getISOWeeksInYear() {
4626 return weeksInYear(this.year(), 1, 4);
4629 function getISOWeeksInISOWeekYear() {
4630 return weeksInYear(this.isoWeekYear(), 1, 4);
4633 function getWeeksInYear() {
4634 var weekInfo
= this.localeData()._week
;
4635 return weeksInYear(this.year(), weekInfo
.dow
, weekInfo
.doy
);
4638 function getWeeksInWeekYear() {
4639 var weekInfo
= this.localeData()._week
;
4640 return weeksInYear(this.weekYear(), weekInfo
.dow
, weekInfo
.doy
);
4643 function getSetWeekYearHelper(input
, week
, weekday
, dow
, doy
) {
4645 if (input
== null) {
4646 return weekOfYear(this, dow
, doy
).year
;
4648 weeksTarget
= weeksInYear(input
, dow
, doy
);
4649 if (week
> weeksTarget
) {
4652 return setWeekAll
.call(this, input
, week
, weekday
, dow
, doy
);
4656 function setWeekAll(weekYear
, week
, weekday
, dow
, doy
) {
4657 var dayOfYearData
= dayOfYearFromWeeks(weekYear
, week
, weekday
, dow
, doy
),
4658 date
= createUTCDate(dayOfYearData
.year
, 0, dayOfYearData
.dayOfYear
);
4660 this.year(date
.getUTCFullYear());
4661 this.month(date
.getUTCMonth());
4662 this.date(date
.getUTCDate());
4668 addFormatToken('Q', 0, 'Qo', 'quarter');
4672 addUnitAlias('quarter', 'Q');
4676 addUnitPriority('quarter', 7);
4680 addRegexToken('Q', match1
);
4681 addParseToken('Q', function (input
, array
) {
4682 array
[MONTH
] = (toInt(input
) - 1) * 3;
4687 function getSetQuarter(input
) {
4688 return input
== null
4689 ? Math
.ceil((this.month() + 1) / 3)
4690 : this.month((input
- 1) * 3 + (this.month() % 3));
4695 addFormatToken('D', ['DD', 2], 'Do', 'date');
4699 addUnitAlias('date', 'D');
4702 addUnitPriority('date', 9);
4706 addRegexToken('D', match1to2
);
4707 addRegexToken('DD', match1to2
, match2
);
4708 addRegexToken('Do', function (isStrict
, locale
) {
4709 // TODO: Remove "ordinalParse" fallback in next major release.
4711 ? locale
._dayOfMonthOrdinalParse
|| locale
._ordinalParse
4712 : locale
._dayOfMonthOrdinalParseLenient
;
4715 addParseToken(['D', 'DD'], DATE
);
4716 addParseToken('Do', function (input
, array
) {
4717 array
[DATE
] = toInt(input
.match(match1to2
)[0]);
4722 var getSetDayOfMonth
= makeGetSet('Date', true);
4726 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
4730 addUnitAlias('dayOfYear', 'DDD');
4733 addUnitPriority('dayOfYear', 4);
4737 addRegexToken('DDD', match1to3
);
4738 addRegexToken('DDDD', match3
);
4739 addParseToken(['DDD', 'DDDD'], function (input
, array
, config
) {
4740 config
._dayOfYear
= toInt(input
);
4747 function getSetDayOfYear(input
) {
4750 (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
4752 return input
== null ? dayOfYear
: this.add(input
- dayOfYear
, 'd');
4757 addFormatToken('m', ['mm', 2], 0, 'minute');
4761 addUnitAlias('minute', 'm');
4765 addUnitPriority('minute', 14);
4769 addRegexToken('m', match1to2
);
4770 addRegexToken('mm', match1to2
, match2
);
4771 addParseToken(['m', 'mm'], MINUTE
);
4775 var getSetMinute
= makeGetSet('Minutes', false);
4779 addFormatToken('s', ['ss', 2], 0, 'second');
4783 addUnitAlias('second', 's');
4787 addUnitPriority('second', 15);
4791 addRegexToken('s', match1to2
);
4792 addRegexToken('ss', match1to2
, match2
);
4793 addParseToken(['s', 'ss'], SECOND
);
4797 var getSetSecond
= makeGetSet('Seconds', false);
4801 addFormatToken('S', 0, 0, function () {
4802 return ~~(this.millisecond() / 100);
4805 addFormatToken(0, ['SS', 2], 0, function () {
4806 return ~~(this.millisecond() / 10);
4809 addFormatToken(0, ['SSS', 3], 0, 'millisecond');
4810 addFormatToken(0, ['SSSS', 4], 0, function () {
4811 return this.millisecond() * 10;
4813 addFormatToken(0, ['SSSSS', 5], 0, function () {
4814 return this.millisecond() * 100;
4816 addFormatToken(0, ['SSSSSS', 6], 0, function () {
4817 return this.millisecond() * 1000;
4819 addFormatToken(0, ['SSSSSSS', 7], 0, function () {
4820 return this.millisecond() * 10000;
4822 addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
4823 return this.millisecond() * 100000;
4825 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
4826 return this.millisecond() * 1000000;
4831 addUnitAlias('millisecond', 'ms');
4835 addUnitPriority('millisecond', 16);
4839 addRegexToken('S', match1to3
, match1
);
4840 addRegexToken('SS', match1to3
, match2
);
4841 addRegexToken('SSS', match1to3
, match3
);
4843 var token
, getSetMillisecond
;
4844 for (token
= 'SSSS'; token
.length
<= 9; token
+= 'S') {
4845 addRegexToken(token
, matchUnsigned
);
4848 function parseMs(input
, array
) {
4849 array
[MILLISECOND
] = toInt(('0.' + input
) * 1000);
4852 for (token
= 'S'; token
.length
<= 9; token
+= 'S') {
4853 addParseToken(token
, parseMs
);
4856 getSetMillisecond
= makeGetSet('Milliseconds', false);
4860 addFormatToken('z', 0, 0, 'zoneAbbr');
4861 addFormatToken('zz', 0, 0, 'zoneName');
4865 function getZoneAbbr() {
4866 return this._isUTC
? 'UTC' : '';
4869 function getZoneName() {
4870 return this._isUTC
? 'Coordinated Universal Time' : '';
4873 var proto
= Moment
.prototype;
4876 proto
.calendar
= calendar
$1;
4877 proto
.clone
= clone
;
4879 proto
.endOf
= endOf
;
4880 proto
.format
= format
;
4882 proto
.fromNow
= fromNow
;
4884 proto
.toNow
= toNow
;
4885 proto
.get = stringGet
;
4886 proto
.invalidAt
= invalidAt
;
4887 proto
.isAfter
= isAfter
;
4888 proto
.isBefore
= isBefore
;
4889 proto
.isBetween
= isBetween
;
4890 proto
.isSame
= isSame
;
4891 proto
.isSameOrAfter
= isSameOrAfter
;
4892 proto
.isSameOrBefore
= isSameOrBefore
;
4893 proto
.isValid
= isValid
$2;
4895 proto
.locale
= locale
;
4896 proto
.localeData
= localeData
;
4897 proto
.max
= prototypeMax
;
4898 proto
.min
= prototypeMin
;
4899 proto
.parsingFlags
= parsingFlags
;
4900 proto
.set = stringSet
;
4901 proto
.startOf
= startOf
;
4902 proto
.subtract
= subtract
;
4903 proto
.toArray
= toArray
;
4904 proto
.toObject
= toObject
;
4905 proto
.toDate
= toDate
;
4906 proto
.toISOString
= toISOString
;
4907 proto
.inspect
= inspect
;
4908 if (typeof Symbol
!== 'undefined' && Symbol
.for != null) {
4909 proto
[Symbol
.for('nodejs.util.inspect.custom')] = function () {
4910 return 'Moment<' + this.format() + '>';
4913 proto
.toJSON
= toJSON
;
4914 proto
.toString
= toString
;
4916 proto
.valueOf
= valueOf
;
4917 proto
.creationData
= creationData
;
4918 proto
.eraName
= getEraName
;
4919 proto
.eraNarrow
= getEraNarrow
;
4920 proto
.eraAbbr
= getEraAbbr
;
4921 proto
.eraYear
= getEraYear
;
4922 proto
.year
= getSetYear
;
4923 proto
.isLeapYear
= getIsLeapYear
;
4924 proto
.weekYear
= getSetWeekYear
;
4925 proto
.isoWeekYear
= getSetISOWeekYear
;
4926 proto
.quarter
= proto
.quarters
= getSetQuarter
;
4927 proto
.month
= getSetMonth
;
4928 proto
.daysInMonth
= getDaysInMonth
;
4929 proto
.week
= proto
.weeks
= getSetWeek
;
4930 proto
.isoWeek
= proto
.isoWeeks
= getSetISOWeek
;
4931 proto
.weeksInYear
= getWeeksInYear
;
4932 proto
.weeksInWeekYear
= getWeeksInWeekYear
;
4933 proto
.isoWeeksInYear
= getISOWeeksInYear
;
4934 proto
.isoWeeksInISOWeekYear
= getISOWeeksInISOWeekYear
;
4935 proto
.date
= getSetDayOfMonth
;
4936 proto
.day
= proto
.days
= getSetDayOfWeek
;
4937 proto
.weekday
= getSetLocaleDayOfWeek
;
4938 proto
.isoWeekday
= getSetISODayOfWeek
;
4939 proto
.dayOfYear
= getSetDayOfYear
;
4940 proto
.hour
= proto
.hours
= getSetHour
;
4941 proto
.minute
= proto
.minutes
= getSetMinute
;
4942 proto
.second
= proto
.seconds
= getSetSecond
;
4943 proto
.millisecond
= proto
.milliseconds
= getSetMillisecond
;
4944 proto
.utcOffset
= getSetOffset
;
4945 proto
.utc
= setOffsetToUTC
;
4946 proto
.local
= setOffsetToLocal
;
4947 proto
.parseZone
= setOffsetToParsedOffset
;
4948 proto
.hasAlignedHourOffset
= hasAlignedHourOffset
;
4949 proto
.isDST
= isDaylightSavingTime
;
4950 proto
.isLocal
= isLocal
;
4951 proto
.isUtcOffset
= isUtcOffset
;
4952 proto
.isUtc
= isUtc
;
4953 proto
.isUTC
= isUtc
;
4954 proto
.zoneAbbr
= getZoneAbbr
;
4955 proto
.zoneName
= getZoneName
;
4956 proto
.dates
= deprecate(
4957 'dates accessor is deprecated. Use date instead.',
4960 proto
.months
= deprecate(
4961 'months accessor is deprecated. Use month instead',
4964 proto
.years
= deprecate(
4965 'years accessor is deprecated. Use year instead',
4968 proto
.zone
= deprecate(
4969 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
4972 proto
.isDSTShifted
= deprecate(
4973 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
4974 isDaylightSavingTimeShifted
4977 function createUnix(input
) {
4978 return createLocal(input
* 1000);
4981 function createInZone() {
4982 return createLocal
.apply(null, arguments
).parseZone();
4985 function preParsePostFormat(string
) {
4989 var proto
$1 = Locale
.prototype;
4991 proto
$1.calendar
= calendar
;
4992 proto
$1.longDateFormat
= longDateFormat
;
4993 proto
$1.invalidDate
= invalidDate
;
4994 proto
$1.ordinal
= ordinal
;
4995 proto
$1.preparse
= preParsePostFormat
;
4996 proto
$1.postformat
= preParsePostFormat
;
4997 proto
$1.relativeTime
= relativeTime
;
4998 proto
$1.pastFuture
= pastFuture
;
5000 proto
$1.eras
= localeEras
;
5001 proto
$1.erasParse
= localeErasParse
;
5002 proto
$1.erasConvertYear
= localeErasConvertYear
;
5003 proto
$1.erasAbbrRegex
= erasAbbrRegex
;
5004 proto
$1.erasNameRegex
= erasNameRegex
;
5005 proto
$1.erasNarrowRegex
= erasNarrowRegex
;
5007 proto
$1.months
= localeMonths
;
5008 proto
$1.monthsShort
= localeMonthsShort
;
5009 proto
$1.monthsParse
= localeMonthsParse
;
5010 proto
$1.monthsRegex
= monthsRegex
;
5011 proto
$1.monthsShortRegex
= monthsShortRegex
;
5012 proto
$1.week
= localeWeek
;
5013 proto
$1.firstDayOfYear
= localeFirstDayOfYear
;
5014 proto
$1.firstDayOfWeek
= localeFirstDayOfWeek
;
5016 proto
$1.weekdays
= localeWeekdays
;
5017 proto
$1.weekdaysMin
= localeWeekdaysMin
;
5018 proto
$1.weekdaysShort
= localeWeekdaysShort
;
5019 proto
$1.weekdaysParse
= localeWeekdaysParse
;
5021 proto
$1.weekdaysRegex
= weekdaysRegex
;
5022 proto
$1.weekdaysShortRegex
= weekdaysShortRegex
;
5023 proto
$1.weekdaysMinRegex
= weekdaysMinRegex
;
5025 proto
$1.isPM
= localeIsPM
;
5026 proto
$1.meridiem
= localeMeridiem
;
5028 function get$1(format
, index
, field
, setter
) {
5029 var locale
= getLocale(),
5030 utc
= createUTC().set(setter
, index
);
5031 return locale
[field
](utc
, format
);
5034 function listMonthsImpl(format
, index
, field
) {
5035 if (isNumber(format
)) {
5040 format
= format
|| '';
5042 if (index
!= null) {
5043 return get$1(format
, index
, field
, 'month');
5048 for (i
= 0; i
< 12; i
++) {
5049 out
[i
] = get$1(format
, i
, field
, 'month');
5062 function listWeekdaysImpl(localeSorted
, format
, index
, field
) {
5063 if (typeof localeSorted
=== 'boolean') {
5064 if (isNumber(format
)) {
5069 format
= format
|| '';
5071 format
= localeSorted
;
5073 localeSorted
= false;
5075 if (isNumber(format
)) {
5080 format
= format
|| '';
5083 var locale
= getLocale(),
5084 shift
= localeSorted
? locale
._week
.dow
: 0,
5088 if (index
!= null) {
5089 return get$1(format
, (index
+ shift
) % 7, field
, 'day');
5092 for (i
= 0; i
< 7; i
++) {
5093 out
[i
] = get$1(format
, (i
+ shift
) % 7, field
, 'day');
5098 function listMonths(format
, index
) {
5099 return listMonthsImpl(format
, index
, 'months');
5102 function listMonthsShort(format
, index
) {
5103 return listMonthsImpl(format
, index
, 'monthsShort');
5106 function listWeekdays(localeSorted
, format
, index
) {
5107 return listWeekdaysImpl(localeSorted
, format
, index
, 'weekdays');
5110 function listWeekdaysShort(localeSorted
, format
, index
) {
5111 return listWeekdaysImpl(localeSorted
, format
, index
, 'weekdaysShort');
5114 function listWeekdaysMin(localeSorted
, format
, index
) {
5115 return listWeekdaysImpl(localeSorted
, format
, index
, 'weekdaysMin');
5118 getSetGlobalLocale('en', {
5121 since
: '0001-01-01',
5124 name
: 'Anno Domini',
5129 since
: '0000-12-31',
5132 name
: 'Before Christ',
5137 dayOfMonthOrdinalParse
: /\d{1,2}(th|st|nd|rd)/,
5138 ordinal: function (number
) {
5139 var b
= number
% 10,
5141 toInt((number
% 100) / 10) === 1
5150 return number
+ output
;
5154 // Side effect imports
5156 hooks
.lang
= deprecate(
5157 'moment.lang is deprecated. Use moment.locale instead.',
5160 hooks
.langData
= deprecate(
5161 'moment.langData is deprecated. Use moment.localeData instead.',
5165 var mathAbs
= Math
.abs
;
5168 var data
= this._data
;
5170 this._milliseconds
= mathAbs(this._milliseconds
);
5171 this._days
= mathAbs(this._days
);
5172 this._months
= mathAbs(this._months
);
5174 data
.milliseconds
= mathAbs(data
.milliseconds
);
5175 data
.seconds
= mathAbs(data
.seconds
);
5176 data
.minutes
= mathAbs(data
.minutes
);
5177 data
.hours
= mathAbs(data
.hours
);
5178 data
.months
= mathAbs(data
.months
);
5179 data
.years
= mathAbs(data
.years
);
5184 function addSubtract
$1(duration
, input
, value
, direction
) {
5185 var other
= createDuration(input
, value
);
5187 duration
._milliseconds
+= direction
* other
._milliseconds
;
5188 duration
._days
+= direction
* other
._days
;
5189 duration
._months
+= direction
* other
._months
;
5191 return duration
._bubble();
5194 // supports only 2.0-style add(1, 's') or add(duration)
5195 function add
$1(input
, value
) {
5196 return addSubtract
$1(this, input
, value
, 1);
5199 // supports only 2.0-style subtract(1, 's') or subtract(duration)
5200 function subtract
$1(input
, value
) {
5201 return addSubtract
$1(this, input
, value
, -1);
5204 function absCeil(number
) {
5206 return Math
.floor(number
);
5208 return Math
.ceil(number
);
5213 var milliseconds
= this._milliseconds
,
5215 months
= this._months
,
5223 // if we have a mix of positive and negative values, bubble down first
5224 // check: https://github.com/moment/moment/issues/2166
5227 (milliseconds
>= 0 && days
>= 0 && months
>= 0) ||
5228 (milliseconds
<= 0 && days
<= 0 && months
<= 0)
5231 milliseconds
+= absCeil(monthsToDays(months
) + days
) * 864e5
;
5236 // The following code bubbles up values, see the tests for
5237 // examples of what that means.
5238 data
.milliseconds
= milliseconds
% 1000;
5240 seconds
= absFloor(milliseconds
/ 1000);
5241 data
.seconds
= seconds
% 60;
5243 minutes
= absFloor(seconds
/ 60);
5244 data
.minutes
= minutes
% 60;
5246 hours
= absFloor(minutes
/ 60);
5247 data
.hours
= hours
% 24;
5249 days
+= absFloor(hours
/ 24);
5251 // convert days to months
5252 monthsFromDays
= absFloor(daysToMonths(days
));
5253 months
+= monthsFromDays
;
5254 days
-= absCeil(monthsToDays(monthsFromDays
));
5256 // 12 months -> 1 year
5257 years
= absFloor(months
/ 12);
5261 data
.months
= months
;
5267 function daysToMonths(days
) {
5268 // 400 years have 146097 days (taking into account leap year rules)
5269 // 400 years have 12 months === 4800
5270 return (days
* 4800) / 146097;
5273 function monthsToDays(months
) {
5274 // the reverse of daysToMonths
5275 return (months
* 146097) / 4800;
5278 function as(units
) {
5279 if (!this.isValid()) {
5284 milliseconds
= this._milliseconds
;
5286 units
= normalizeUnits(units
);
5288 if (units
=== 'month' || units
=== 'quarter' || units
=== 'year') {
5289 days
= this._days
+ milliseconds
/ 864e5
;
5290 months
= this._months
+ daysToMonths(days
);
5300 // handle milliseconds separately because of floating point math errors (issue #1867)
5301 days
= this._days
+ Math
.round(monthsToDays(this._months
));
5304 return days
/ 7 + milliseconds
/ 6048e5
;
5306 return days
+ milliseconds
/ 864e5
;
5308 return days
* 24 + milliseconds
/ 36e5
;
5310 return days
* 1440 + milliseconds
/ 6e4
;
5312 return days
* 86400 + milliseconds
/ 1000;
5313 // Math.floor prevents floating point math errors here
5315 return Math
.floor(days
* 864e5
) + milliseconds
;
5317 throw new Error('Unknown unit ' + units
);
5322 // TODO: Use this.as('ms')?
5323 function valueOf
$1() {
5324 if (!this.isValid()) {
5328 this._milliseconds
+
5329 this._days
* 864e5
+
5330 (this._months
% 12) * 2592e6
+
5331 toInt(this._months
/ 12) * 31536e6
5335 function makeAs(alias
) {
5336 return function () {
5337 return this.as(alias
);
5341 var asMilliseconds
= makeAs('ms'),
5342 asSeconds
= makeAs('s'),
5343 asMinutes
= makeAs('m'),
5344 asHours
= makeAs('h'),
5345 asDays
= makeAs('d'),
5346 asWeeks
= makeAs('w'),
5347 asMonths
= makeAs('M'),
5348 asQuarters
= makeAs('Q'),
5349 asYears
= makeAs('y');
5351 function clone
$1() {
5352 return createDuration(this);
5355 function get$2(units
) {
5356 units
= normalizeUnits(units
);
5357 return this.isValid() ? this[units
+ 's']() : NaN
;
5360 function makeGetter(name
) {
5361 return function () {
5362 return this.isValid() ? this._data
[name
] : NaN
;
5366 var milliseconds
= makeGetter('milliseconds'),
5367 seconds
= makeGetter('seconds'),
5368 minutes
= makeGetter('minutes'),
5369 hours
= makeGetter('hours'),
5370 days
= makeGetter('days'),
5371 months
= makeGetter('months'),
5372 years
= makeGetter('years');
5375 return absFloor(this.days() / 7);
5378 var round
= Math
.round
,
5380 ss
: 44, // a few seconds to seconds
5381 s
: 45, // seconds to minute
5382 m
: 45, // minutes to hour
5383 h
: 22, // hours to day
5384 d
: 26, // days to month/week
5385 w
: null, // weeks to month
5386 M
: 11, // months to year
5389 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
5390 function substituteTimeAgo(string
, number
, withoutSuffix
, isFuture
, locale
) {
5391 return locale
.relativeTime(number
|| 1, !!withoutSuffix
, string
, isFuture
);
5394 function relativeTime
$1(posNegDuration
, withoutSuffix
, thresholds
, locale
) {
5395 var duration
= createDuration(posNegDuration
).abs(),
5396 seconds
= round(duration
.as('s')),
5397 minutes
= round(duration
.as('m')),
5398 hours
= round(duration
.as('h')),
5399 days
= round(duration
.as('d')),
5400 months
= round(duration
.as('M')),
5401 weeks
= round(duration
.as('w')),
5402 years
= round(duration
.as('y')),
5404 (seconds
<= thresholds
.ss
&& ['s', seconds
]) ||
5405 (seconds
< thresholds
.s
&& ['ss', seconds
]) ||
5406 (minutes
<= 1 && ['m']) ||
5407 (minutes
< thresholds
.m
&& ['mm', minutes
]) ||
5408 (hours
<= 1 && ['h']) ||
5409 (hours
< thresholds
.h
&& ['hh', hours
]) ||
5410 (days
<= 1 && ['d']) ||
5411 (days
< thresholds
.d
&& ['dd', days
]);
5413 if (thresholds
.w
!= null) {
5416 (weeks
<= 1 && ['w']) ||
5417 (weeks
< thresholds
.w
&& ['ww', weeks
]);
5420 (months
<= 1 && ['M']) ||
5421 (months
< thresholds
.M
&& ['MM', months
]) ||
5422 (years
<= 1 && ['y']) || ['yy', years
];
5424 a
[2] = withoutSuffix
;
5425 a
[3] = +posNegDuration
> 0;
5427 return substituteTimeAgo
.apply(null, a
);
5430 // This function allows you to set the rounding function for relative time strings
5431 function getSetRelativeTimeRounding(roundingFunction
) {
5432 if (roundingFunction
=== undefined) {
5435 if (typeof roundingFunction
=== 'function') {
5436 round
= roundingFunction
;
5442 // This function allows you to set a threshold for relative time strings
5443 function getSetRelativeTimeThreshold(threshold
, limit
) {
5444 if (thresholds
[threshold
] === undefined) {
5447 if (limit
=== undefined) {
5448 return thresholds
[threshold
];
5450 thresholds
[threshold
] = limit
;
5451 if (threshold
=== 's') {
5452 thresholds
.ss
= limit
- 1;
5457 function humanize(argWithSuffix
, argThresholds
) {
5458 if (!this.isValid()) {
5459 return this.localeData().invalidDate();
5462 var withSuffix
= false,
5467 if (typeof argWithSuffix
=== 'object') {
5468 argThresholds
= argWithSuffix
;
5469 argWithSuffix
= false;
5471 if (typeof argWithSuffix
=== 'boolean') {
5472 withSuffix
= argWithSuffix
;
5474 if (typeof argThresholds
=== 'object') {
5475 th
= Object
.assign({}, thresholds
, argThresholds
);
5476 if (argThresholds
.s
!= null && argThresholds
.ss
== null) {
5477 th
.ss
= argThresholds
.s
- 1;
5481 locale
= this.localeData();
5482 output
= relativeTime
$1(this, !withSuffix
, th
, locale
);
5485 output
= locale
.pastFuture(+this, output
);
5488 return locale
.postformat(output
);
5491 var abs
$1 = Math
.abs
;
5494 return (x
> 0) - (x
< 0) || +x
;
5497 function toISOString
$1() {
5498 // for ISO strings we do not use the normal bubbling rules:
5499 // * milliseconds bubble up until they become hours
5500 // * days do not bubble at all
5501 // * months bubble up until they become years
5502 // This is because there is no context-free conversion between hours and days
5503 // (think of clock changes)
5504 // and also not between days and months (28-31 days per month)
5505 if (!this.isValid()) {
5506 return this.localeData().invalidDate();
5509 var seconds
= abs
$1(this._milliseconds
) / 1000,
5510 days
= abs
$1(this._days
),
5511 months
= abs
$1(this._months
),
5516 total
= this.asSeconds(),
5523 // this is the same as C#'s (Noda) and python (isodate)...
5524 // but not other JS (goog.date)
5528 // 3600 seconds -> 60 minutes -> 1 hour
5529 minutes
= absFloor(seconds
/ 60);
5530 hours
= absFloor(minutes
/ 60);
5534 // 12 months -> 1 year
5535 years
= absFloor(months
/ 12);
5538 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
5539 s
= seconds
? seconds
.toFixed(3).replace(/\.?0+$/, '') : '';
5541 totalSign
= total
< 0 ? '-' : '';
5542 ymSign
= sign(this._months
) !== sign(total
) ? '-' : '';
5543 daysSign
= sign(this._days
) !== sign(total
) ? '-' : '';
5544 hmsSign
= sign(this._milliseconds
) !== sign(total
) ? '-' : '';
5549 (years
? ymSign
+ years
+ 'Y' : '') +
5550 (months
? ymSign
+ months
+ 'M' : '') +
5551 (days
? daysSign
+ days
+ 'D' : '') +
5552 (hours
|| minutes
|| seconds
? 'T' : '') +
5553 (hours
? hmsSign
+ hours
+ 'H' : '') +
5554 (minutes
? hmsSign
+ minutes
+ 'M' : '') +
5555 (seconds
? hmsSign
+ s
+ 'S' : '')
5559 var proto
$2 = Duration
.prototype;
5561 proto
$2.isValid
= isValid
$1;
5563 proto
$2.add
= add
$1;
5564 proto
$2.subtract
= subtract
$1;
5566 proto
$2.asMilliseconds
= asMilliseconds
;
5567 proto
$2.asSeconds
= asSeconds
;
5568 proto
$2.asMinutes
= asMinutes
;
5569 proto
$2.asHours
= asHours
;
5570 proto
$2.asDays
= asDays
;
5571 proto
$2.asWeeks
= asWeeks
;
5572 proto
$2.asMonths
= asMonths
;
5573 proto
$2.asQuarters
= asQuarters
;
5574 proto
$2.asYears
= asYears
;
5575 proto
$2.valueOf
= valueOf
$1;
5576 proto
$2._bubble
= bubble
;
5577 proto
$2.clone
= clone
$1;
5578 proto
$2.get = get$2;
5579 proto
$2.milliseconds
= milliseconds
;
5580 proto
$2.seconds
= seconds
;
5581 proto
$2.minutes
= minutes
;
5582 proto
$2.hours
= hours
;
5583 proto
$2.days
= days
;
5584 proto
$2.weeks
= weeks
;
5585 proto
$2.months
= months
;
5586 proto
$2.years
= years
;
5587 proto
$2.humanize
= humanize
;
5588 proto
$2.toISOString
= toISOString
$1;
5589 proto
$2.toString
= toISOString
$1;
5590 proto
$2.toJSON
= toISOString
$1;
5591 proto
$2.locale
= locale
;
5592 proto
$2.localeData
= localeData
;
5594 proto
$2.toIsoString
= deprecate(
5595 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
5598 proto
$2.lang
= lang
;
5602 addFormatToken('X', 0, 0, 'unix');
5603 addFormatToken('x', 0, 0, 'valueOf');
5607 addRegexToken('x', matchSigned
);
5608 addRegexToken('X', matchTimestamp
);
5609 addParseToken('X', function (input
, array
, config
) {
5610 config
._d
= new Date(parseFloat(input
) * 1000);
5612 addParseToken('x', function (input
, array
, config
) {
5613 config
._d
= new Date(toInt(input
));
5618 hooks
.version
= '2.29.0';
5620 setHookCallback(createLocal
);
5626 hooks
.utc
= createUTC
;
5627 hooks
.unix
= createUnix
;
5628 hooks
.months
= listMonths
;
5629 hooks
.isDate
= isDate
;
5630 hooks
.locale
= getSetGlobalLocale
;
5631 hooks
.invalid
= createInvalid
;
5632 hooks
.duration
= createDuration
;
5633 hooks
.isMoment
= isMoment
;
5634 hooks
.weekdays
= listWeekdays
;
5635 hooks
.parseZone
= createInZone
;
5636 hooks
.localeData
= getLocale
;
5637 hooks
.isDuration
= isDuration
;
5638 hooks
.monthsShort
= listMonthsShort
;
5639 hooks
.weekdaysMin
= listWeekdaysMin
;
5640 hooks
.defineLocale
= defineLocale
;
5641 hooks
.updateLocale
= updateLocale
;
5642 hooks
.locales
= listLocales
;
5643 hooks
.weekdaysShort
= listWeekdaysShort
;
5644 hooks
.normalizeUnits
= normalizeUnits
;
5645 hooks
.relativeTimeRounding
= getSetRelativeTimeRounding
;
5646 hooks
.relativeTimeThreshold
= getSetRelativeTimeThreshold
;
5647 hooks
.calendarFormat
= getCalendarFormat
;
5648 hooks
.prototype = proto
;
5650 // currently HTML5 input type only supports 24-hour formats
5652 DATETIME_LOCAL
: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
5653 DATETIME_LOCAL_SECONDS
: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
5654 DATETIME_LOCAL_MS
: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
5655 DATE
: 'YYYY-MM-DD', // <input type="date" />
5656 TIME
: 'HH:mm', // <input type="time" />
5657 TIME_SECONDS
: 'HH:mm:ss', // <input type="time" step="1" />
5658 TIME_MS
: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
5659 WEEK
: 'GGGG-[W]WW', // <input type="week" />
5660 MONTH
: 'YYYY-MM', // <input type="month" />
5663 export default hooks
;