if (locale === true || locale === false) {
(isObject(input) && isObjectEmpty(input)) ||
(isArray(input) && input.length === 0)
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
c._isAMomentObject = true;
c._useUTC = c._isUTC = isUTC;
return createFromConfig(c);
function createLocal(input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, false);
var prototypeMin = deprecate(
'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
prototypeMax = deprecate(
'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
if (moments.length === 1 && isArray(moments[0])) {
for (i = 1; i < moments.length; ++i) {
if (!moments[i].isValid() || moments[i][fn](res)) {
// TODO: Use [].sort instead?
var args = [].slice.call(arguments, 0);
return pickBy('isBefore', args);
var args = [].slice.call(arguments, 0);
return pickBy('isAfter', args);
return Date.now ? Date.now() : +new Date();
function isDurationValid(m) {
indexOf.call(ordering, key) !== -1 &&
(m[key] == null || !isNaN(m[key]))
for (i = 0; i < ordering.length; ++i) {
return false; // only allow non-integers for smallest unit
if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
function createInvalid$1() {
return createDuration(NaN);
function Duration(duration) {
var normalizedInput = normalizeObjectUnits(duration),
years = normalizedInput.year || 0,
quarters = normalizedInput.quarter || 0,
months = normalizedInput.month || 0,
weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
days = normalizedInput.day || 0,
hours = normalizedInput.hour || 0,
minutes = normalizedInput.minute || 0,
seconds = normalizedInput.second || 0,
milliseconds = normalizedInput.millisecond || 0;
this._isValid = isDurationValid(normalizedInput);
// representation for dateAddRemove
minutes * 6e4 + // 1000 * 60
hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days + weeks * 7;
// It is impossible to translate months into days without knowing
// which months you are are talking about, so we have to store
this._months = +months + quarters * 3 + years * 12;
this._locale = getLocale();
function isDuration(obj) {
return obj instanceof Duration;
function absRound(number) {
return Math.round(-1 * number) * -1;
return Math.round(number);
// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length),
lengthDiff = Math.abs(array1.length - array2.length),
for (i = 0; i < len; i++) {
(dontConvert && array1[i] !== array2[i]) ||
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
return diffs + lengthDiff;
function offset(token, separator) {
addFormatToken(token, 0, 0, function () {
var offset = this.utcOffset(),
zeroFill(~~(offset / 60), 2) +
zeroFill(~~offset % 60, 2)
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
config._tzm = offsetFromString(matchShortOffset, input);
// '+10:00' > ['10', '00']
// '-1530' > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, string) {
var matches = (string || '').match(matcher),
chunk = matches[matches.length - 1] || [];
parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
minutes = +(parts[1] * 60) + toInt(parts[2]);
return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, model) {
(isMoment(input) || isDate(input)
: createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
res._d.setTime(res._d.valueOf() + diff);
hooks.updateOffset(res, false);
return createLocal(input).local();
function getDateOffset(m) {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return -Math.round(m._d.getTimezoneOffset());
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks.updateOffset = function () {};
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getSetOffset(input, keepLocalTime, keepMinutes) {
var offset = this._offset || 0,
return input != null ? this : NaN;
if (typeof input === 'string') {
input = offsetFromString(matchShortOffset, input);
} else if (Math.abs(input) < 16 && !keepMinutes) {
if (!this._isUTC && keepLocalTime) {
localAdjust = getDateOffset(this);
if (localAdjust != null) {
this.add(localAdjust, 'm');
if (!keepLocalTime || this._changeInProgress) {
createDuration(input - offset, 'm'),
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks.updateOffset(this, true);
this._changeInProgress = null;
return this._isUTC ? offset : getDateOffset(this);
function getSetZone(input, keepLocalTime) {
if (typeof input !== 'string') {
this.utcOffset(input, keepLocalTime);
return -this.utcOffset();
function setOffsetToUTC(keepLocalTime) {
return this.utcOffset(0, keepLocalTime);
function setOffsetToLocal(keepLocalTime) {
this.utcOffset(0, keepLocalTime);
this.subtract(getDateOffset(this), 'm');
function setOffsetToParsedOffset() {
this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === 'string') {
var tZone = offsetFromString(matchOffset, this._i);
function hasAlignedHourOffset(input) {
input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
function isDaylightSavingTime() {
this.utcOffset() > this.clone().month(0).utcOffset() ||
this.utcOffset() > this.clone().month(5).utcOffset()
function isDaylightSavingTimeShifted() {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this.isValid() && compareArrays(c._a, other.toArray()) > 0;
this._isDSTShifted = false;
return this._isDSTShifted;
return this.isValid() ? !this._isUTC : false;
return this.isValid() ? this._isUTC : false;
return this.isValid() ? this._isUTC && this._offset === 0 : false;
// ASP.NET json date format regex
var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
function createDuration(input, key) {
// matching against regexp is expensive, do it on demand
} else if (isNumber(input) || !isNaN(+input)) {
duration.milliseconds = +input;
} else if ((match = aspNetRegex.exec(input))) {
sign = match[1] === '-' ? -1 : 1;
d: toInt(match[DATE]) * sign,
h: toInt(match[HOUR]) * sign,
m: toInt(match[MINUTE]) * sign,
s: toInt(match[SECOND]) * sign,
ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
} else if ((match = isoRegex.exec(input))) {
sign = match[1] === '-' ? -1 : 1;
y: parseIso(match[2], sign),
M: parseIso(match[3], sign),
w: parseIso(match[4], sign),
d: parseIso(match[5], sign),
h: parseIso(match[6], sign),
m: parseIso(match[7], sign),
s: parseIso(match[8], sign),
} else if (duration == null) {
// checks for null or undefined
typeof duration === 'object' &&
('from' in duration || 'to' in duration)
diffRes = momentsDifference(
createLocal(duration.from),