//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.moment = factory()
}(this, (function () { 'use strict';
return hookCallback.apply(null, arguments);
// This is done to register the method called with moment()
// without creating circular dependencies.
function setHookCallback(callback) {
function isArray(input) {
input instanceof Array ||
Object.prototype.toString.call(input) === '[object Array]'
function isObject(input) {
// IE8 will treat undefined and null as object if it wasn't for
Object.prototype.toString.call(input) === '[object Object]'
function hasOwnProp(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
function isObjectEmpty(obj) {
if (Object.getOwnPropertyNames) {
return Object.getOwnPropertyNames(obj).length === 0;
if (hasOwnProp(obj, k)) {
function isUndefined(input) {
function isNumber(input) {
typeof input === 'number' ||
Object.prototype.toString.call(input) === '[object Number]'
Object.prototype.toString.call(input) === '[object Date]'
for (i = 0; i < arr.length; ++i) {
if (hasOwnProp(b, 'toString')) {
if (hasOwnProp(b, 'valueOf')) {
function createUTC(input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, true).utc();
function defaultParsingFlags() {
// We need to deep clone this object.
function getParsingFlags(m) {
m._pf = defaultParsingFlags();
if (Array.prototype.some) {
some = Array.prototype.some;
for (i = 0; i < len; i++) {
if (i in t && fun.call(this, t[i], i, t)) {
if (m._isValid == null) {
var flags = getParsingFlags(m),
parsedParts = some.call(flags.parsedDateParts, function (i) {
!isNaN(m._d.getTime()) &&
!flags.weekdayMismatch &&
!flags.userInvalidated &&
(!flags.meridiem || (flags.meridiem && parsedParts));
flags.charsLeftOver === 0 &&
flags.unusedTokens.length === 0 &&
flags.bigHour === undefined;
if (Object.isFrozen == null || !Object.isFrozen(m)) {
function createInvalid(flags) {
extend(getParsingFlags(m), flags);
getParsingFlags(m).userInvalidated = true;
// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = (hooks.momentProperties = []),
updateInProgress = false;
function copyConfig(to, from) {
if (!isUndefined(from._isAMomentObject)) {
to._isAMomentObject = from._isAMomentObject;
if (!isUndefined(from._i)) {
if (!isUndefined(from._f)) {
if (!isUndefined(from._l)) {
if (!isUndefined(from._strict)) {
to._strict = from._strict;
if (!isUndefined(from._tzm)) {
if (!isUndefined(from._isUTC)) {
if (!isUndefined(from._offset)) {
to._offset = from._offset;
if (!isUndefined(from._pf)) {
to._pf = getParsingFlags(from);
if (!isUndefined(from._locale)) {
to._locale = from._locale;
if (momentProperties.length > 0) {
for (i = 0; i < momentProperties.length; i++) {
prop = momentProperties[i];
// Moment prototype object
function Moment(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
// Prevent infinite loop in case updateOffset creates new moment
if (updateInProgress === false) {
hooks.updateOffset(this);
updateInProgress = false;
obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
hooks.suppressDeprecationWarnings === false &&
typeof console !== 'undefined' &&
console.warn('Deprecation warning: ' + msg);
function deprecate(msg, fn) {
return extend(function () {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(null, msg);
for (i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'object') {
for (key in arguments[0]) {
if (hasOwnProp(arguments[0], key)) {
arg += key + ': ' + arguments[0][key] + ', ';
arg = arg.slice(0, -2); // Remove trailing comma and space
Array.prototype.slice.call(args).join('') +
return fn.apply(this, arguments);
function deprecateSimple(name, msg) {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(name, msg);
if (!deprecations[name]) {
deprecations[name] = true;
hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;
function isFunction(input) {
(typeof Function !== 'undefined' && input instanceof Function) ||
Object.prototype.toString.call(input) === '[object Function]'
if (hasOwnProp(config, i)) {
// Lenient ordinal parsing accepts just a number in addition to
// number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
// TODO: Remove "ordinalParse" fallback in next major release.
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
function mergeConfigs(parentConfig, childConfig) {
var res = extend({}, parentConfig),
for (prop in childConfig) {
if (hasOwnProp(childConfig, prop)) {
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
extend(res[prop], parentConfig[prop]);
extend(res[prop], childConfig[prop]);
} else if (childConfig[prop] != null) {
res[prop] = childConfig[prop];
for (prop in parentConfig) {
hasOwnProp(parentConfig, prop) &&
!hasOwnProp(childConfig, prop) &&
isObject(parentConfig[prop])
// make sure changes to properties don't modify parent config
res[prop] = extend({}, res[prop]);
function Locale(config) {
if (hasOwnProp(obj, i)) {
sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
nextWeek: 'dddd [at] LT',
lastDay: '[Yesterday at] LT',
lastWeek: '[Last] dddd [at] LT',
function calendar(key, mom, now) {
var output = this._calendar[key] || this._calendar['sameElse'];
return isFunction(output) ? output.call(mom, now) : output;
function zeroFill(number, targetLength, forceSign) {
var absNumber = '' + Math.abs(number),
zerosToFill = targetLength - absNumber.length,
(sign ? (forceSign ? '+' : '') : '-') +
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
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,
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
formatTokenFunctions = {};
// callback: function () { this.month() + 1 }
function addFormatToken(token, padded, ordinal, callback) {
if (typeof callback === 'string') {
formatTokenFunctions[token] = func;
formatTokenFunctions[padded[0]] = function () {
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
formatTokenFunctions[ordinal] = function () {
return this.localeData().ordinal(
func.apply(this, arguments),
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, '');
return input.replace(/\\/g, '');
function makeFormatFunction(format) {
var array = format.match(formattingTokens),
for (i = 0, length = array.length; i < length; i++) {
if (formatTokenFunctions[array[i]]) {
array[i] = formatTokenFunctions[array[i]];
array[i] = removeFormattingTokens(array[i]);