Skip to content

Business intelligence made simple

Updated Moment.js - closes #532

Andrew Kaned78743fbfb38
diff --git a/app/assets/javascripts/blazer/moment.js b/app/assets/javascripts/blazer/moment.js
index 480b9fb3..6b922fc0 100644
--- a/app/assets/javascripts/blazer/moment.js
+++ b/app/assets/javascripts/blazer/moment.js
@@ -1,5 +1,5 @@
//! moment.js
-//! version : 2.30.1
+//! version : 2.31.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
@@ -117,6 +117,7 @@
nullInput: false,
invalidEra: null,
invalidMonth: null,
+ invalidOffset: null,
invalidFormat: false,
userInvalidated: false,
iso: false,
@@ -154,7 +155,7 @@
};
}
- function isValid(m) {
+ function isValid$2(m) {
var flags = null,
parsedParts = false,
isNowValid = m._d && !isNaN(m._d.getTime());
@@ -168,6 +169,7 @@
!flags.empty &&
!flags.invalidEra &&
!flags.invalidMonth &&
+ !flags.invalidOffset &&
!flags.invalidWeekday &&
!flags.weekdayMismatch &&
!flags.nullInput &&
@@ -190,7 +192,7 @@
return m._isValid;
}
- function createInvalid(flags) {
+ function createInvalid$1(flags) {
var m = createUTC(NaN);
if (flags != null) {
extend(getParsingFlags(m), flags);
@@ -336,7 +338,7 @@
hooks.deprecationHandler(name, msg);
}
if (!deprecations[name]) {
- warn(msg);
+ warn(msg + '\n' + new Error().stack);
deprecations[name] = true;
}
}
@@ -351,93 +353,111 @@
);
}
- function set(config) {
- var prop, i;
- for (i in config) {
- if (hasOwnProp(config, i)) {
- prop = config[i];
- if (isFunction(prop)) {
- this[i] = prop;
- } else {
- this['_' + i] = prop;
- }
- }
- }
- this._config = config;
- // 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) +
- '|' +
- /\d{1,2}/.source
- );
+ var aliases = {
+ D: 'date',
+ dates: 'date',
+ date: 'date',
+ d: 'day',
+ days: 'day',
+ day: 'day',
+ e: 'weekday',
+ weekdays: 'weekday',
+ weekday: 'weekday',
+ E: 'isoWeekday',
+ isoweekdays: 'isoWeekday',
+ isoweekday: 'isoWeekday',
+ DDD: 'dayOfYear',
+ dayofyears: 'dayOfYear',
+ dayofyear: 'dayOfYear',
+ h: 'hour',
+ hours: 'hour',
+ hour: 'hour',
+ ms: 'millisecond',
+ milliseconds: 'millisecond',
+ millisecond: 'millisecond',
+ m: 'minute',
+ minutes: 'minute',
+ minute: 'minute',
+ M: 'month',
+ months: 'month',
+ month: 'month',
+ Q: 'quarter',
+ quarters: 'quarter',
+ quarter: 'quarter',
+ s: 'second',
+ seconds: 'second',
+ second: 'second',
+ gg: 'weekYear',
+ weekyears: 'weekYear',
+ weekyear: 'weekYear',
+ GG: 'isoWeekYear',
+ isoweekyears: 'isoWeekYear',
+ isoweekyear: 'isoWeekYear',
+ w: 'week',
+ weeks: 'week',
+ week: 'week',
+ W: 'isoWeek',
+ isoweeks: 'isoWeek',
+ isoweek: 'isoWeek',
+ y: 'year',
+ years: 'year',
+ year: 'year',
+ };
+
+ function normalizeUnits(units) {
+ return typeof units === 'string'
+ ? aliases[units] || aliases[units.toLowerCase()]
+ : undefined;
}
- function mergeConfigs(parentConfig, childConfig) {
- var res = extend({}, parentConfig),
+ function normalizeObjectUnits(inputObject) {
+ var normalizedInput = {},
+ normalizedProp,
prop;
- for (prop in childConfig) {
- if (hasOwnProp(childConfig, prop)) {
- if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
- res[prop] = {};
- extend(res[prop], parentConfig[prop]);
- extend(res[prop], childConfig[prop]);
- } else if (childConfig[prop] != null) {
- res[prop] = childConfig[prop];
- } else {
- delete res[prop];
+
+ for (prop in inputObject) {
+ if (hasOwnProp(inputObject, prop)) {
+ normalizedProp = normalizeUnits(prop);
+ if (normalizedProp) {
+ normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
- for (prop in parentConfig) {
- if (
- hasOwnProp(parentConfig, prop) &&
- !hasOwnProp(childConfig, prop) &&
- isObject(parentConfig[prop])
- ) {
- // make sure changes to properties don't modify parent config
- res[prop] = extend({}, res[prop]);
- }
- }
- return res;
- }
-
- function Locale(config) {
- if (config != null) {
- this.set(config);
- }
- }
-
- var keys;
- if (Object.keys) {
- keys = Object.keys;
- } else {
- keys = function (obj) {
- var i,
- res = [];
- for (i in obj) {
- if (hasOwnProp(obj, i)) {
- res.push(i);
- }
- }
- return res;
- };
+ return normalizedInput;
}
- var defaultCalendar = {
- sameDay: '[Today at] LT',
- nextDay: '[Tomorrow at] LT',
- nextWeek: 'dddd [at] LT',
- lastDay: '[Yesterday at] LT',
- lastWeek: '[Last] dddd [at] LT',
- sameElse: 'L',
+ var priorities = {
+ date: 9,
+ day: 11,
+ weekday: 11,
+ isoWeekday: 11,
+ dayOfYear: 4,
+ hour: 13,
+ millisecond: 16,
+ minute: 14,
+ month: 8,
+ quarter: 7,
+ second: 15,
+ weekYear: 1,
+ isoWeekYear: 1,
+ week: 5,
+ isoWeek: 5,
+ year: 1,
};
- function calendar(key, mom, now) {
- var output = this._calendar[key] || this._calendar['sameElse'];
- return isFunction(output) ? output.call(mom, now) : output;
+ function getPrioritizedUnits(unitsObj) {
+ var units = [],
+ u;
+ for (u in unitsObj) {
+ if (hasOwnProp(unitsObj, u)) {
+ units.push({ unit: u, priority: priorities[u] });
+ }
+ }
+ units.sort(function (a, b) {
+ return a.priority - b.priority;
+ });
+ return units;
}
function zeroFill(number, targetLength, forceSign) {
@@ -452,7 +472,7 @@
}
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,
+ /(\[[^\[]*\])|(\\e)|(\\)?(eHHmm|[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,
formatFunctions = {},
formatTokenFunctions = {};
@@ -525,10 +545,12 @@
}
format = expandFormat(format, m.localeData());
- formatFunctions[format] =
- formatFunctions[format] || makeFormatFunction(format);
+ var cacheKey = '$' + format;
+ if (!hasOwnProp(formatFunctions, cacheKey)) {
+ formatFunctions[cacheKey] = makeFormatFunction(format);
+ }
- return formatFunctions[format](m);
+ return formatFunctions[cacheKey](m);
}
function expandFormat(format, locale) {
@@ -551,250 +573,64 @@
return format;
}
- var defaultLongDateFormat = {
- LTS: 'h:mm:ss A',
- LT: 'h:mm A',
- L: 'MM/DD/YYYY',
- LL: 'MMMM D, YYYY',
- LLL: 'MMMM D, YYYY h:mm A',
- LLLL: 'dddd, MMMM D, YYYY h:mm A',
- };
-
- function longDateFormat(key) {
- var format = this._longDateFormat[key],
- formatUpper = this._longDateFormat[key.toUpperCase()];
-
- if (format || !formatUpper) {
- return format;
- }
+ var match1 = /\d/, // 0 - 9
+ match2 = /\d\d/, // 00 - 99
+ match3 = /\d{3}/, // 000 - 999
+ match4 = /\d{4}/, // 0000 - 9999
+ match6 = /[+-]?\d{6}/, // -999999 - 999999
+ match1to2 = /\d\d?/, // 0 - 99
+ match3to4 = /\d\d\d\d?/, // 999 - 9999
+ match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
+ match1to3 = /\d{1,3}/, // 0 - 999
+ match1to4 = /\d{1,4}/, // 0 - 9999
+ match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
+ matchUnsigned = /\d+/, // 0 - inf
+ matchSigned = /[+-]?\d+/, // -inf - inf
+ matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
+ matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
+ matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
+ // any word (or two) characters or numbers including two/three word month in arabic.
+ // includes scottish gaelic two word and hyphenated months
+ 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,
+ match1to2NoLeadingZero = /^[1-9]\d?/, // 1-99
+ match1to2HasZero = /^([1-9]\d|\d)/, // 0-99
+ regexes;
- this._longDateFormat[key] = formatUpper
- .match(formattingTokens)
- .map(function (tok) {
- if (
- tok === 'MMMM' ||
- tok === 'MM' ||
- tok === 'DD' ||
- tok === 'dddd'
- ) {
- return tok.slice(1);
- }
- return tok;
- })
- .join('');
+ regexes = {};
- return this._longDateFormat[key];
+ function addRegexToken(token, regex, strictRegex) {
+ regexes[token] = isFunction(regex)
+ ? regex
+ : function (isStrict, localeData) {
+ return isStrict && strictRegex ? strictRegex : regex;
+ };
}
- var defaultInvalidDate = 'Invalid date';
+ function getParseRegexForToken(token, config) {
+ if (!hasOwnProp(regexes, token)) {
+ return new RegExp(unescapeFormat(token));
+ }
- function invalidDate() {
- return this._invalidDate;
+ return regexes[token](config._strict, config._locale);
}
- var defaultOrdinal = '%d',
- defaultDayOfMonthOrdinalParse = /\d{1,2}/;
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+ function unescapeFormat(s) {
+ return regexEscape(
+ s
+ .replace('\\', '')
+ .replace(
+ /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
+ function (matched, p1, p2, p3, p4) {
+ return p1 || p2 || p3 || p4;
+ }
+ )
+ );
+ }
- function ordinal(number) {
- return this._ordinal.replace('%d', number);
- }
-
- var defaultRelativeTime = {
- future: 'in %s',
- past: '%s ago',
- s: 'a few seconds',
- ss: '%d seconds',
- m: 'a minute',
- mm: '%d minutes',
- h: 'an hour',
- hh: '%d hours',
- d: 'a day',
- dd: '%d days',
- w: 'a week',
- ww: '%d weeks',
- M: 'a month',
- MM: '%d months',
- y: 'a year',
- yy: '%d years',
- };
-
- function relativeTime(number, withoutSuffix, string, isFuture) {
- var output = this._relativeTime[string];
- return isFunction(output)
- ? output(number, withoutSuffix, string, isFuture)
- : output.replace(/%d/i, number);
- }
-
- function pastFuture(diff, output) {
- var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
- return isFunction(format) ? format(output) : format.replace(/%s/i, output);
- }
-
- var aliases = {
- D: 'date',
- dates: 'date',
- date: 'date',
- d: 'day',
- days: 'day',
- day: 'day',
- e: 'weekday',
- weekdays: 'weekday',
- weekday: 'weekday',
- E: 'isoWeekday',
- isoweekdays: 'isoWeekday',
- isoweekday: 'isoWeekday',
- DDD: 'dayOfYear',
- dayofyears: 'dayOfYear',
- dayofyear: 'dayOfYear',
- h: 'hour',
- hours: 'hour',
- hour: 'hour',
- ms: 'millisecond',
- milliseconds: 'millisecond',
- millisecond: 'millisecond',
- m: 'minute',
- minutes: 'minute',
- minute: 'minute',
- M: 'month',
- months: 'month',
- month: 'month',
- Q: 'quarter',
- quarters: 'quarter',
- quarter: 'quarter',
- s: 'second',
- seconds: 'second',
- second: 'second',
- gg: 'weekYear',
- weekyears: 'weekYear',
- weekyear: 'weekYear',
- GG: 'isoWeekYear',
- isoweekyears: 'isoWeekYear',
- isoweekyear: 'isoWeekYear',
- w: 'week',
- weeks: 'week',
- week: 'week',
- W: 'isoWeek',
- isoweeks: 'isoWeek',
- isoweek: 'isoWeek',
- y: 'year',
- years: 'year',
- year: 'year',
- };
-
- function normalizeUnits(units) {
- return typeof units === 'string'
- ? aliases[units] || aliases[units.toLowerCase()]
- : undefined;
- }
-
- function normalizeObjectUnits(inputObject) {
- var normalizedInput = {},
- normalizedProp,
- prop;
-
- for (prop in inputObject) {
- if (hasOwnProp(inputObject, prop)) {
- normalizedProp = normalizeUnits(prop);
- if (normalizedProp) {
- normalizedInput[normalizedProp] = inputObject[prop];
- }
- }
- }
-
- return normalizedInput;
- }
-
- var priorities = {
- date: 9,
- day: 11,
- weekday: 11,
- isoWeekday: 11,
- dayOfYear: 4,
- hour: 13,
- millisecond: 16,
- minute: 14,
- month: 8,
- quarter: 7,
- second: 15,
- weekYear: 1,
- isoWeekYear: 1,
- week: 5,
- isoWeek: 5,
- year: 1,
- };
-
- function getPrioritizedUnits(unitsObj) {
- var units = [],
- u;
- for (u in unitsObj) {
- if (hasOwnProp(unitsObj, u)) {
- units.push({ unit: u, priority: priorities[u] });
- }
- }
- units.sort(function (a, b) {
- return a.priority - b.priority;
- });
- return units;
- }
-
- var match1 = /\d/, // 0 - 9
- match2 = /\d\d/, // 00 - 99
- match3 = /\d{3}/, // 000 - 999
- match4 = /\d{4}/, // 0000 - 9999
- match6 = /[+-]?\d{6}/, // -999999 - 999999
- match1to2 = /\d\d?/, // 0 - 99
- match3to4 = /\d\d\d\d?/, // 999 - 9999
- match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
- match1to3 = /\d{1,3}/, // 0 - 999
- match1to4 = /\d{1,4}/, // 0 - 9999
- match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
- matchUnsigned = /\d+/, // 0 - inf
- matchSigned = /[+-]?\d+/, // -inf - inf
- matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
- matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
- matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
- // any word (or two) characters or numbers including two/three word month in arabic.
- // includes scottish gaelic two word and hyphenated months
- 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,
- match1to2NoLeadingZero = /^[1-9]\d?/, // 1-99
- match1to2HasZero = /^([1-9]\d|\d)/, // 0-99
- regexes;
-
- regexes = {};
-
- function addRegexToken(token, regex, strictRegex) {
- regexes[token] = isFunction(regex)
- ? regex
- : function (isStrict, localeData) {
- return isStrict && strictRegex ? strictRegex : regex;
- };
- }
-
- function getParseRegexForToken(token, config) {
- if (!hasOwnProp(regexes, token)) {
- return new RegExp(unescapeFormat(token));
- }
-
- return regexes[token](config._strict, config._locale);
- }
-
- // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
- function unescapeFormat(s) {
- return regexEscape(
- s
- .replace('\\', '')
- .replace(
- /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
- function (matched, p1, p2, p3, p4) {
- return p1 || p2 || p3 || p4;
- }
- )
- );
- }
-
- function regexEscape(s) {
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ function regexEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
function absFloor(number) {
@@ -926,12 +762,12 @@
hooks.updateOffset(this, keepTime);
return this;
} else {
- return get(this, unit);
+ return get$2(this, unit);
}
};
}
- function get(mom, unit) {
+ function get$2(mom, unit) {
if (!mom.isValid()) {
return NaN;
}
@@ -1031,7 +867,7 @@
return this;
}
- function mod(n, x) {
+ function mod$1(n, x) {
return ((n % x) + x) % x;
}
@@ -1056,7 +892,7 @@
if (isNaN(year) || isNaN(month)) {
return NaN;
}
- var modMonth = mod(month, 12);
+ var modMonth = mod$1(month, 12);
year += (month - modMonth) / 12;
return modMonth === 1
? isLeapYear(year)
@@ -1114,7 +950,26 @@
'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
defaultMonthsShortRegex = matchWord,
- defaultMonthsRegex = matchWord;
+ defaultMonthsRegex = matchWord,
+ monthsParseProperties = [
+ 'monthsParse',
+ 'longMonthsParse',
+ 'shortMonthsParse',
+ 'monthsRegex',
+ 'monthsShortRegex',
+ 'monthsStrictRegex',
+ 'monthsShortStrictRegex',
+ ];
+
+ function clearMonthsParseCache(locale, config) {
+ var i, prop;
+ for (i = 0; i < monthsParseProperties.length; i++) {
+ prop = monthsParseProperties[i];
+ if (!hasOwnProp(config, prop)) {
+ delete locale['_' + prop];
+ }
+ }
+ }
function localeMonths(m, format) {
if (!m) {
@@ -1144,7 +999,7 @@
][m.month()];
}
- function handleStrictParse(monthName, format, strict) {
+ function handleStrictParse$1(monthName, format, strict) {
var i,
ii,
mom,
@@ -1195,7 +1050,7 @@
var i, mom, regex;
if (this._monthsParseExact) {
- return handleStrictParse.call(this, monthName, format, strict);
+ return handleStrictParse$1.call(this, monthName, format, strict);
}
if (!this._monthsParse) {
@@ -1280,7 +1135,7 @@
hooks.updateOffset(this, true);
return this;
} else {
- return get(this, 'Month');
+ return get$2(this, 'Month');
}
}
@@ -1368,182 +1223,39 @@
);
}
- function createDate(y, m, d, h, M, s, ms) {
- // can't just apply() to create a date:
- // https://stackoverflow.com/q/181348
- var date;
- // the date constructor remaps years 0-99 to 1900-1999
- if (y < 100 && y >= 0) {
- // preserve leap years using a full 400 year cycle, then reset
- date = new Date(y + 400, m, d, h, M, s, ms);
- if (isFinite(date.getFullYear())) {
- date.setFullYear(y);
- }
- } else {
- date = new Date(y, m, d, h, M, s, ms);
- }
-
- return date;
- }
+ // FORMATTING
- function createUTCDate(y) {
- var date, args;
- // the Date.UTC function remaps years 0-99 to 1900-1999
- if (y < 100 && y >= 0) {
- args = Array.prototype.slice.call(arguments);
- // preserve leap years using a full 400 year cycle, then reset
- args[0] = y + 400;
- date = new Date(Date.UTC.apply(null, args));
- if (isFinite(date.getUTCFullYear())) {
- date.setUTCFullYear(y);
- }
- } else {
- date = new Date(Date.UTC.apply(null, arguments));
- }
+ addFormatToken('d', 0, 'do', 'day');
- return date;
- }
+ addFormatToken('dd', 0, 0, function (format) {
+ return this.localeData().weekdaysMin(this, format);
+ });
- // start-of-first-week - start-of-year
- function firstWeekOffset(year, dow, doy) {
- var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
- fwd = 7 + dow - doy,
- // first-week day local weekday -- which local weekday is fwd
- fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
+ addFormatToken('ddd', 0, 0, function (format) {
+ return this.localeData().weekdaysShort(this, format);
+ });
- return -fwdlw + fwd - 1;
- }
-
- // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
- function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
- var localWeekday = (7 + weekday - dow) % 7,
- weekOffset = firstWeekOffset(year, dow, doy),
- dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
- resYear,
- resDayOfYear;
-
- if (dayOfYear <= 0) {
- resYear = year - 1;
- resDayOfYear = daysInYear(resYear) + dayOfYear;
- } else if (dayOfYear > daysInYear(year)) {
- resYear = year + 1;
- resDayOfYear = dayOfYear - daysInYear(year);
- } else {
- resYear = year;
- resDayOfYear = dayOfYear;
- }
-
- return {
- year: resYear,
- dayOfYear: resDayOfYear,
- };
- }
-
- function weekOfYear(mom, dow, doy) {
- var weekOffset = firstWeekOffset(mom.year(), dow, doy),
- week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
- resWeek,
- resYear;
-
- if (week < 1) {
- resYear = mom.year() - 1;
- resWeek = week + weeksInYear(resYear, dow, doy);
- } else if (week > weeksInYear(mom.year(), dow, doy)) {
- resWeek = week - weeksInYear(mom.year(), dow, doy);
- resYear = mom.year() + 1;
- } else {
- resYear = mom.year();
- resWeek = week;
- }
-
- return {
- week: resWeek,
- year: resYear,
- };
- }
-
- function weeksInYear(year, dow, doy) {
- var weekOffset = firstWeekOffset(year, dow, doy),
- weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
- return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
- }
-
- // FORMATTING
-
- addFormatToken('w', ['ww', 2], 'wo', 'week');
- addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
-
- // PARSING
-
- addRegexToken('w', match1to2, match1to2NoLeadingZero);
- addRegexToken('ww', match1to2, match2);
- addRegexToken('W', match1to2, match1to2NoLeadingZero);
- addRegexToken('WW', match1to2, match2);
-
- addWeekParseToken(
- ['w', 'ww', 'W', 'WW'],
- function (input, week, config, token) {
- week[token.substr(0, 1)] = toInt(input);
- }
- );
-
- // HELPERS
-
- // LOCALES
-
- function localeWeek(mom) {
- return weekOfYear(mom, this._week.dow, this._week.doy).week;
- }
-
- var defaultLocaleWeek = {
- dow: 0, // Sunday is the first day of the week.
- doy: 6, // The week that contains Jan 6th is the first week of the year.
- };
-
- function localeFirstDayOfWeek() {
- return this._week.dow;
- }
-
- function localeFirstDayOfYear() {
- return this._week.doy;
- }
-
- // MOMENTS
-
- function getSetWeek(input) {
- var week = this.localeData().week(this);
- return input == null ? week : this.add((input - week) * 7, 'd');
- }
-
- function getSetISOWeek(input) {
- var week = weekOfYear(this, 1, 4).week;
- return input == null ? week : this.add((input - week) * 7, 'd');
- }
-
- // FORMATTING
-
- addFormatToken('d', 0, 'do', 'day');
-
- addFormatToken('dd', 0, 0, function (format) {
- return this.localeData().weekdaysMin(this, format);
- });
-
- addFormatToken('ddd', 0, 0, function (format) {
- return this.localeData().weekdaysShort(this, format);
- });
-
- addFormatToken('dddd', 0, 0, function (format) {
- return this.localeData().weekdays(this, format);
- });
+ addFormatToken('dddd', 0, 0, function (format) {
+ return this.localeData().weekdays(this, format);
+ });
addFormatToken('e', 0, 0, 'weekday');
addFormatToken('E', 0, 0, 'isoWeekday');
+ addFormatToken('eHHmm', 0, 0, function () {
+ return (
+ '' +
+ this.weekday() +
+ zeroFill(this.hours(), 2) +
+ zeroFill(this.minutes(), 2)
+ );
+ });
// PARSING
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
+ addRegexToken('eHHmm', match5to6);
addRegexToken('dd', function (isStrict, locale) {
return locale.weekdaysMinRegex(isStrict);
});
@@ -1568,6 +1280,14 @@
week[token] = toInt(input);
});
+ addWeekParseToken('eHHmm', function (input, week, config) {
+ var weekdayEnd = input.length - 4;
+
+ week.e = toInt(input.substr(0, weekdayEnd));
+ config._a[HOUR] = toInt(input.substr(weekdayEnd, 2));
+ config._a[MINUTE] = toInt(input.substr(weekdayEnd + 2));
+ });
+
// HELPERS
function parseWeekday(input, locale) {
@@ -1605,7 +1325,29 @@
defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
defaultWeekdaysRegex = matchWord,
defaultWeekdaysShortRegex = matchWord,
- defaultWeekdaysMinRegex = matchWord;
+ defaultWeekdaysMinRegex = matchWord,
+ weekdaysParseProperties = [
+ 'weekdaysParse',
+ 'fullWeekdaysParse',
+ 'shortWeekdaysParse',
+ 'minWeekdaysParse',
+ 'weekdaysRegex',
+ 'weekdaysShortRegex',
+ 'weekdaysMinRegex',
+ 'weekdaysStrictRegex',
+ 'weekdaysShortStrictRegex',
+ 'weekdaysMinStrictRegex',
+ ];
+
+ function clearWeekdaysParseCache(locale, config) {
+ var i, prop;
+ for (i = 0; i < weekdaysParseProperties.length; i++) {
+ prop = weekdaysParseProperties[i];
+ if (!hasOwnProp(config, prop)) {
+ delete locale['_' + prop];
+ }
+ }
+ }
function localeWeekdays(m, format) {
var weekdays = isArray(this._weekdays)
@@ -1638,7 +1380,7 @@
: this._weekdaysMin;
}
- function handleStrictParse$1(weekdayName, format, strict) {
+ function handleStrictParse(weekdayName, format, strict) {
var i,
ii,
mom,
@@ -1715,7 +1457,7 @@
var i, mom, regex;
if (this._weekdaysParseExact) {
- return handleStrictParse$1.call(this, weekdayName, format, strict);
+ return handleStrictParse.call(this, weekdayName, format, strict);
}
if (!this._weekdaysParse) {
@@ -1778,157 +1520,532 @@
}
}
- // MOMENTS
+ // MOMENTS
+
+ function getSetDayOfWeek(input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+
+ var day = get$2(this, 'Day');
+ if (input != null) {
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
+ } else {
+ return day;
+ }
+ }
+
+ function getSetLocaleDayOfWeek(input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
+ }
+
+ function getSetISODayOfWeek(input) {
+ if (!this.isValid()) {
+ return input != null ? this : NaN;
+ }
+
+ // behaves the same as moment#day except
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
+ // as a setter, sunday should belong to the previous week.
+
+ if (input != null) {
+ var weekday = parseIsoWeekday(input, this.localeData());
+ return this.day(this.day() % 7 ? weekday : weekday - 7);
+ } else {
+ return this.day() || 7;
+ }
+ }
+
+ function weekdaysRegex(isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysStrictRegex;
+ } else {
+ return this._weekdaysRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ this._weekdaysRegex = defaultWeekdaysRegex;
+ }
+ return this._weekdaysStrictRegex && isStrict
+ ? this._weekdaysStrictRegex
+ : this._weekdaysRegex;
+ }
+ }
+
+ function weekdaysShortRegex(isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysShortStrictRegex;
+ } else {
+ return this._weekdaysShortRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysShortRegex')) {
+ this._weekdaysShortRegex = defaultWeekdaysShortRegex;
+ }
+ return this._weekdaysShortStrictRegex && isStrict
+ ? this._weekdaysShortStrictRegex
+ : this._weekdaysShortRegex;
+ }
+ }
+
+ function weekdaysMinRegex(isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysMinStrictRegex;
+ } else {
+ return this._weekdaysMinRegex;
+ }
+ } else {
+ if (!hasOwnProp(this, '_weekdaysMinRegex')) {
+ this._weekdaysMinRegex = defaultWeekdaysMinRegex;
+ }
+ return this._weekdaysMinStrictRegex && isStrict
+ ? this._weekdaysMinStrictRegex
+ : this._weekdaysMinRegex;
+ }
+ }
+
+ function computeWeekdaysParse() {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var minPieces = [],
+ shortPieces = [],
+ longPieces = [],
+ mixedPieces = [],
+ i,
+ mom,
+ minp,
+ shortp,
+ longp;
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, 1]).day(i);
+ minp = regexEscape(this.weekdaysMin(mom, ''));
+ shortp = regexEscape(this.weekdaysShort(mom, ''));
+ longp = regexEscape(this.weekdays(mom, ''));
+ minPieces.push(minp);
+ shortPieces.push(shortp);
+ longPieces.push(longp);
+ mixedPieces.push(minp);
+ mixedPieces.push(shortp);
+ mixedPieces.push(longp);
+ }
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
+ // will match the longer piece.
+ minPieces.sort(cmpLenRev);
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._weekdaysShortRegex = this._weekdaysRegex;
+ this._weekdaysMinRegex = this._weekdaysRegex;
+
+ this._weekdaysStrictRegex = new RegExp(
+ '^(' + longPieces.join('|') + ')',
+ 'i'
+ );
+ this._weekdaysShortStrictRegex = new RegExp(
+ '^(' + shortPieces.join('|') + ')',
+ 'i'
+ );
+ this._weekdaysMinStrictRegex = new RegExp(
+ '^(' + minPieces.join('|') + ')',
+ 'i'
+ );
+ }
+
+ function set(config) {
+ var prop, i;
+ clearMonthsParseCache(this, config);
+ clearWeekdaysParseCache(this, config);
+ for (i in config) {
+ if (hasOwnProp(config, i)) {
+ prop = config[i];
+ if (isFunction(prop)) {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ }
+ this._config = config;
+ // 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) +
+ '|' +
+ /\d{1,2}/.source
+ );
+ }
+
+ function mergeConfigs(parentConfig, childConfig) {
+ var res = extend({}, parentConfig),
+ prop;
+ for (prop in childConfig) {
+ if (hasOwnProp(childConfig, prop)) {
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
+ res[prop] = {};
+ extend(res[prop], parentConfig[prop]);
+ extend(res[prop], childConfig[prop]);
+ } else if (childConfig[prop] != null) {
+ res[prop] = childConfig[prop];
+ } else {
+ delete res[prop];
+ }
+ }
+ }
+ for (prop in parentConfig) {
+ if (
+ hasOwnProp(parentConfig, prop) &&
+ !hasOwnProp(childConfig, prop) &&
+ isObject(parentConfig[prop])
+ ) {
+ // make sure changes to properties don't modify parent config
+ res[prop] = extend({}, res[prop]);
+ }
+ }
+ return res;
+ }
+
+ function Locale(config) {
+ if (config != null) {
+ this.set(config);
+ }
+ }
+
+ var keys;
+
+ if (Object.keys) {
+ keys = Object.keys;
+ } else {
+ keys = function (obj) {
+ var i,
+ res = [];
+ for (i in obj) {
+ if (hasOwnProp(obj, i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ };
+ }
+
+ var defaultCalendar = {
+ sameDay: '[Today at] LT',
+ nextDay: '[Tomorrow at] LT',
+ nextWeek: 'dddd [at] LT',
+ lastDay: '[Yesterday at] LT',
+ lastWeek: '[Last] dddd [at] LT',
+ sameElse: 'L',
+ };
+
+ function calendar$1(key, mom, now) {
+ var output = this._calendar[key] || this._calendar['sameElse'];
+ return isFunction(output) ? output.call(mom, now) : output;
+ }
+
+ var defaultLongDateFormat = {
+ LTS: 'h:mm:ss A',
+ LT: 'h:mm A',
+ L: 'MM/DD/YYYY',
+ LL: 'MMMM D, YYYY',
+ LLL: 'MMMM D, YYYY h:mm A',
+ LLLL: 'dddd, MMMM D, YYYY h:mm A',
+ };
+
+ function longDateFormat(key) {
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()],
+ formatCache = this._longDateFormatCache;
+
+ if (format || !formatUpper) {
+ return format;
+ }
+
+ if (
+ formatCache &&
+ formatCache[key] &&
+ formatCache[key].formatUpper === formatUpper
+ ) {
+ return formatCache[key].format;
+ }
+
+ format = formatUpper
+ .match(formattingTokens)
+ .map(function (tok) {
+ if (
+ tok === 'MMMM' ||
+ tok === 'MM' ||
+ tok === 'DD' ||
+ tok === 'dddd'
+ ) {
+ return tok.slice(1);
+ }
+ return tok;
+ })
+ .join('');
+
+ if (!formatCache) {
+ formatCache = this._longDateFormatCache = {};
+ }
+ formatCache[key] = {
+ formatUpper: formatUpper,
+ format: format,
+ };
+ return format;
+ }
+
+ var defaultInvalidDate = 'Invalid date';
+
+ function invalidDate() {
+ return this._invalidDate;
+ }
+
+ var defaultOrdinal = '%d',
+ defaultDayOfMonthOrdinalParse = /\d{1,2}/;
+
+ function ordinal(number) {
+ return this._ordinal.replace('%d', number);
+ }
+
+ var defaultRelativeTime = {
+ future: 'in %s',
+ past: '%s ago',
+ s: 'a few seconds',
+ ss: '%d seconds',
+ m: 'a minute',
+ mm: '%d minutes',
+ h: 'an hour',
+ hh: '%d hours',
+ d: 'a day',
+ dd: '%d days',
+ w: 'a week',
+ ww: '%d weeks',
+ M: 'a month',
+ MM: '%d months',
+ y: 'a year',
+ yy: '%d years',
+ };
+
+ function relativeTimeWithoutPostformat(
+ number,
+ withoutSuffix,
+ string,
+ isFuture
+ ) {
+ var output = this._relativeTime[string];
+ return isFunction(output)
+ ? output(number, withoutSuffix, string, isFuture)
+ : output.replace(/%d/i, number);
+ }
+
+ function relativeTime$1(number, withoutSuffix, string, isFuture) {
+ return this.postformat(
+ relativeTimeWithoutPostformat.call(
+ this,
+ number,
+ withoutSuffix,
+ string,
+ isFuture
+ )
+ );
+ }
+
+ function pastFutureWithoutPostformat(diff, output) {
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
+ return isFunction(format) ? format(output) : format.replace(/%s/i, output);
+ }
+
+ function pastFuture(diff, output) {
+ return this.postformat(
+ pastFutureWithoutPostformat.call(this, diff, output)
+ );
+ }
+
+ function createDate(y, m, d, h, M, s, ms) {
+ // can't just apply() to create a date:
+ // https://stackoverflow.com/q/181348
+ var date;
+ // the date constructor remaps years 0-99 to 1900-1999
+ if (y < 100 && y >= 0) {
+ // preserve leap years using a full 400 year cycle, then reset
+ date = new Date(y + 400, m, d, h, M, s, ms);
+ if (isFinite(date.getFullYear())) {
+ date.setFullYear(y);
+ }
+ } else {
+ date = new Date(y, m, d, h, M, s, ms);
+ }
+
+ return date;
+ }
+
+ function createUTCDate(y) {
+ var date, args;
+ // the Date.UTC function remaps years 0-99 to 1900-1999
+ if (y < 100 && y >= 0) {
+ args = Array.prototype.slice.call(arguments);
+ // preserve leap years using a full 400 year cycle, then reset
+ args[0] = y + 400;
+ date = new Date(Date.UTC.apply(null, args));
+ if (isFinite(date.getUTCFullYear())) {
+ date.setUTCFullYear(y);
+ }
+ } else {
+ date = new Date(Date.UTC.apply(null, arguments));
+ }
+
+ return date;
+ }
+
+ // start-of-first-week - start-of-year
+ function firstWeekOffset(year, dow, doy) {
+ var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
+ fwd = 7 + dow - doy,
+ // first-week day local weekday -- which local weekday is fwd
+ fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
+
+ return -fwdlw + fwd - 1;
+ }
+
+ // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
+ function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
+ var localWeekday = (7 + weekday - dow) % 7,
+ weekOffset = firstWeekOffset(year, dow, doy),
+ dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
+ resYear,
+ resDayOfYear;
+
+ if (dayOfYear <= 0) {
+ resYear = year - 1;
+ resDayOfYear = daysInYear(resYear) + dayOfYear;
+ } else if (dayOfYear > daysInYear(year)) {
+ resYear = year + 1;
+ resDayOfYear = dayOfYear - daysInYear(year);
+ } else {
+ resYear = year;
+ resDayOfYear = dayOfYear;
+ }
+
+ return {
+ year: resYear,
+ dayOfYear: resDayOfYear,
+ };
+ }
+
+ function weekOfYearFromDayOfYear(year, dayOfYear, dow, doy) {
+ var weekOffset = firstWeekOffset(year, dow, doy),
+ week = Math.floor((dayOfYear - weekOffset - 1) / 7) + 1,
+ resWeek,
+ resYear;
+
+ if (week < 1) {
+ resYear = year - 1;
+ resWeek = week + weeksInYear(resYear, dow, doy);
+ } else if (week > weeksInYear(year, dow, doy)) {
+ resWeek = week - weeksInYear(year, dow, doy);
+ resYear = year + 1;
+ } else {
+ resYear = year;
+ resWeek = week;
+ }
+
+ return {
+ week: resWeek,
+ year: resYear,
+ };
+ }
+
+ function weekOfYear(mom, dow, doy) {
+ return weekOfYearFromDayOfYear(mom.year(), mom.dayOfYear(), dow, doy);
+ }
+
+ function weekOfYearFromDate(year, month, date, dow, doy) {
+ var dayOfYear =
+ Math.round(
+ (createUTCDate(year, month, date) - createUTCDate(year, 0, 1)) /
+ 864e5
+ ) + 1;
+
+ return weekOfYearFromDayOfYear(year, dayOfYear, dow, doy);
+ }
+
+ function weeksInYear(year, dow, doy) {
+ var weekOffset = firstWeekOffset(year, dow, doy),
+ weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
+ return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
+ }
+
+ // FORMATTING
- function getSetDayOfWeek(input) {
- if (!this.isValid()) {
- return input != null ? this : NaN;
- }
+ addFormatToken('w', ['ww', 2], 'wo', 'week');
+ addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
- var day = get(this, 'Day');
- if (input != null) {
- input = parseWeekday(input, this.localeData());
- return this.add(input - day, 'd');
- } else {
- return day;
- }
- }
+ // PARSING
- function getSetLocaleDayOfWeek(input) {
- if (!this.isValid()) {
- return input != null ? this : NaN;
- }
- var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
- return input == null ? weekday : this.add(input - weekday, 'd');
- }
+ addRegexToken('w', match1to2, match1to2NoLeadingZero);
+ addRegexToken('ww', match1to2, match2);
+ addRegexToken('W', match1to2, match1to2NoLeadingZero);
+ addRegexToken('WW', match1to2, match2);
- function getSetISODayOfWeek(input) {
- if (!this.isValid()) {
- return input != null ? this : NaN;
+ addWeekParseToken(
+ ['w', 'ww', 'W', 'WW'],
+ function (input, week, config, token) {
+ week[token.substr(0, 1)] = toInt(input);
}
+ );
- // behaves the same as moment#day except
- // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
- // as a setter, sunday should belong to the previous week.
+ // HELPERS
- if (input != null) {
- var weekday = parseIsoWeekday(input, this.localeData());
- return this.day(this.day() % 7 ? weekday : weekday - 7);
- } else {
- return this.day() || 7;
- }
- }
+ // LOCALES
- function weekdaysRegex(isStrict) {
- if (this._weekdaysParseExact) {
- if (!hasOwnProp(this, '_weekdaysRegex')) {
- computeWeekdaysParse.call(this);
- }
- if (isStrict) {
- return this._weekdaysStrictRegex;
- } else {
- return this._weekdaysRegex;
- }
- } else {
- if (!hasOwnProp(this, '_weekdaysRegex')) {
- this._weekdaysRegex = defaultWeekdaysRegex;
- }
- return this._weekdaysStrictRegex && isStrict
- ? this._weekdaysStrictRegex
- : this._weekdaysRegex;
- }
+ function localeWeek(mom) {
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
}
- function weekdaysShortRegex(isStrict) {
- if (this._weekdaysParseExact) {
- if (!hasOwnProp(this, '_weekdaysRegex')) {
- computeWeekdaysParse.call(this);
- }
- if (isStrict) {
- return this._weekdaysShortStrictRegex;
- } else {
- return this._weekdaysShortRegex;
- }
- } else {
- if (!hasOwnProp(this, '_weekdaysShortRegex')) {
- this._weekdaysShortRegex = defaultWeekdaysShortRegex;
- }
- return this._weekdaysShortStrictRegex && isStrict
- ? this._weekdaysShortStrictRegex
- : this._weekdaysShortRegex;
- }
- }
+ var defaultLocaleWeek = {
+ dow: 0, // Sunday is the first day of the week.
+ doy: 6, // The week that contains Jan 6th is the first week of the year.
+ };
- function weekdaysMinRegex(isStrict) {
- if (this._weekdaysParseExact) {
- if (!hasOwnProp(this, '_weekdaysRegex')) {
- computeWeekdaysParse.call(this);
- }
- if (isStrict) {
- return this._weekdaysMinStrictRegex;
- } else {
- return this._weekdaysMinRegex;
- }
- } else {
- if (!hasOwnProp(this, '_weekdaysMinRegex')) {
- this._weekdaysMinRegex = defaultWeekdaysMinRegex;
- }
- return this._weekdaysMinStrictRegex && isStrict
- ? this._weekdaysMinStrictRegex
- : this._weekdaysMinRegex;
- }
+ function localeFirstDayOfWeek() {
+ return this._week.dow;
}
- function computeWeekdaysParse() {
- function cmpLenRev(a, b) {
- return b.length - a.length;
- }
+ function localeFirstDayOfYear() {
+ return this._week.doy;
+ }
- var minPieces = [],
- shortPieces = [],
- longPieces = [],
- mixedPieces = [],
- i,
- mom,
- minp,
- shortp,
- longp;
- for (i = 0; i < 7; i++) {
- // make the regex if we don't have it already
- mom = createUTC([2000, 1]).day(i);
- minp = regexEscape(this.weekdaysMin(mom, ''));
- shortp = regexEscape(this.weekdaysShort(mom, ''));
- longp = regexEscape(this.weekdays(mom, ''));
- minPieces.push(minp);
- shortPieces.push(shortp);
- longPieces.push(longp);
- mixedPieces.push(minp);
- mixedPieces.push(shortp);
- mixedPieces.push(longp);
- }
- // Sorting makes sure if one weekday (or abbr) is a prefix of another it
- // will match the longer piece.
- minPieces.sort(cmpLenRev);
- shortPieces.sort(cmpLenRev);
- longPieces.sort(cmpLenRev);
- mixedPieces.sort(cmpLenRev);
+ // MOMENTS
- this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
- this._weekdaysShortRegex = this._weekdaysRegex;
- this._weekdaysMinRegex = this._weekdaysRegex;
+ function getSetWeek(input) {
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ }
- this._weekdaysStrictRegex = new RegExp(
- '^(' + longPieces.join('|') + ')',
- 'i'
- );
- this._weekdaysShortStrictRegex = new RegExp(
- '^(' + shortPieces.join('|') + ')',
- 'i'
- );
- this._weekdaysMinStrictRegex = new RegExp(
- '^(' + minPieces.join('|') + ')',
- 'i'
- );
+ function getSetISOWeek(input) {
+ var week = weekOfYear(this, 1, 4).week;
+ return input == null ? week : this.add((input - week) * 7, 'd');
}
// FORMATTING
@@ -2143,34 +2260,49 @@
}
function isLocaleNameSane(name) {
- // Prevent names that look like filesystem paths, i.e contain '/' or '\'
- // Ensure name is available and function returns boolean
- return !!(name && name.match('^[^/\\\\]*$'));
+ // Only canonical locale module names are safe to append to the require path.
+ return typeof name === 'string' && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name);
}
function loadLocale(name) {
var oldLocale = null,
- aliasedRequire;
+ aliasedRequire,
+ normalizedName;
+
+ // Preserve exact custom locale names before trying the canonical built-in name.
+ // Use hasOwnProp rather than a plain lookup so that names like "__proto__",
+ // "constructor", or "prototype" can't resolve to an inherited Object.prototype
+ // property instead of a real (or missing) locale entry.
+ if (hasOwnProp(locales, name)) {
+ return locales[name];
+ }
+
+ normalizedName = normalizeLocale(name);
+ if (hasOwnProp(locales, normalizedName)) {
+ return locales[normalizedName];
+ }
+
// TODO: Find a better way to register and load all the locales in Node
if (
- locales[name] === undefined &&
typeof module !== 'undefined' &&
module &&
module.exports &&
- isLocaleNameSane(name)
+ isLocaleNameSane(normalizedName)
) {
try {
oldLocale = globalLocale._abbr;
aliasedRequire = require;
- aliasedRequire('./locale/' + name);
+ aliasedRequire('./locale/' + normalizedName);
getSetGlobalLocale(oldLocale);
} catch (e) {
// mark as not found to avoid repeating expensive file require call causing high CPU
// when trying to find en-US, en_US, en-us for every format call
- locales[name] = null; // null means not found
+ locales[normalizedName] = null; // null means not found
}
}
- return locales[name];
+ if (hasOwnProp(locales, normalizedName)) {
+ return locales[normalizedName];
+ }
}
// This function will load locale and then set the global locale. If
@@ -2256,17 +2388,20 @@
}
function updateLocale(name, config) {
- if (config != null) {
- var locale,
- tmpLocale,
- parentConfig = baseConfig;
+ var locale,
+ tmpLocale = loadLocale(name),
+ parentConfig = baseConfig;
+ if (tmpLocale != null) {
+ name = tmpLocale._abbr;
+ }
+
+ if (config != null) {
if (locales[name] != null && locales[name].parentLocale != null) {
// Update existing child locale in-place to avoid memory-leaks
locales[name].set(mergeConfigs(locales[name]._config, config));
} else {
// MERGE
- tmpLocale = loadLocale(name);
if (tmpLocale != null) {
parentConfig = tmpLocale._config;
}
@@ -2634,9 +2769,46 @@
return c;
}
- function currentDateArray(config) {
+ function currentDateArray(config, now, forWeek) {
+ var hadWeekContext = Object.prototype.hasOwnProperty.call(
+ config,
+ '_isDefaultDatePartsForWeek'
+ ),
+ weekContext = config._isDefaultDatePartsForWeek;
+
// hooks is actually the exported moment object
- var nowValue = new Date(hooks.now());
+ config._isDefaultDatePartsForWeek = !!forWeek;
+ try {
+ return hooks._getDefaultDateParts(config, now, forWeek);
+ } finally {
+ if (hadWeekContext) {
+ config._isDefaultDatePartsForWeek = weekContext;
+ } else {
+ delete config._isDefaultDatePartsForWeek;
+ }
+ }
+ }
+
+ function currentDateNow(config) {
+ var now = config._defaultDatePartsNow;
+
+ if (!now) {
+ return hooks.now();
+ }
+ if (!now.hasValue) {
+ now.value = hooks.now();
+ now.hasValue = true;
+ }
+ return now.value;
+ }
+
+ // Internal hook for extensions that supply omitted calendar fields.
+ function getDefaultDateParts(config, now, forWeek) {
+ var useWeekDefaults = forWeek || config._isDefaultDatePartsForWeek,
+ nowValue = useWeekDefaults ? createLocal(now) : new Date(now);
+ if (useWeekDefaults) {
+ return [nowValue.year(), nowValue.month(), nowValue.date()];
+ }
if (config._useUTC) {
return [
nowValue.getUTCFullYear(),
@@ -2647,6 +2819,8 @@
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
+ hooks._getDefaultDateParts = getDefaultDateParts;
+
// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
@@ -2655,24 +2829,34 @@
var i,
date,
input = [],
+ now,
currentDate,
expectedWeekday,
- yearToUse;
+ yearToUse,
+ dateIsDefaulted;
if (config._d) {
return;
}
- currentDate = currentDateArray(config);
+ if (
+ config._a[YEAR] == null ||
+ config._a[MONTH] == null ||
+ config._a[DATE] == null
+ ) {
+ now = currentDateNow(config);
+ currentDate = currentDateArray(config, now);
+ }
//compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
- dayOfYearFromWeekInfo(config);
+ dayOfYearFromWeekInfo(config, currentDateArray(config, now, true));
}
//if the day of the year is set, figure out what it is
if (config._dayOfYear != null) {
- yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
+ yearToUse =
+ config._a[YEAR] != null ? config._a[YEAR] : currentDate[YEAR];
if (
config._dayOfYear > daysInYear(yearToUse) ||
@@ -2686,6 +2870,11 @@
config._a[DATE] = date.getUTCDate();
}
+ dateIsDefaulted =
+ config._a[YEAR] == null ||
+ config._a[MONTH] == null ||
+ config._a[DATE] == null;
+
// Default to current date.
// * if no year, month, day of month are given, default to today
// * if day of month is given, default month and year
@@ -2734,13 +2923,14 @@
if (
config._w &&
typeof config._w.d !== 'undefined' &&
+ !dateIsDefaulted &&
config._w.d !== expectedWeekday
) {
getParsingFlags(config).weekdayMismatch = true;
}
}
- function dayOfYearFromWeekInfo(config) {
+ function dayOfYearFromWeekInfo(config, currentDate) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
w = config._w;
@@ -2755,7 +2945,13 @@
weekYear = defaults(
w.GG,
config._a[YEAR],
- weekOfYear(createLocal(), 1, 4).year
+ weekOfYearFromDate(
+ currentDate[YEAR],
+ currentDate[MONTH],
+ currentDate[DATE],
+ 1,
+ 4
+ ).year
);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
@@ -2766,7 +2962,13 @@
dow = config._locale._week.dow;
doy = config._locale._week.doy;
- curWeek = weekOfYear(createLocal(), dow, doy);
+ curWeek = weekOfYearFromDate(
+ currentDate[YEAR],
+ currentDate[MONTH],
+ currentDate[DATE],
+ dow,
+ doy
+ );
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
@@ -2932,6 +3134,7 @@
currentScore,
validFormatFound,
bestFormatIsValid = false,
+ defaultDatePartsNow = {},
configfLen = config._f.length;
if (configfLen === 0) {
@@ -2947,10 +3150,11 @@
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
+ tempConfig._defaultDatePartsNow = defaultDatePartsNow;
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
- if (isValid(tempConfig)) {
+ if (isValid$2(tempConfig)) {
validFormatFound = true;
}
@@ -3020,7 +3224,7 @@
config._locale = config._locale || getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
- return createInvalid({ nullInput: true });
+ return createInvalid$1({ nullInput: true });
}
if (typeof input === 'string') {
@@ -3039,7 +3243,7 @@
configFromInput(config);
}
- if (!isValid(config)) {
+ if (!isValid$2(config)) {
config._d = null;
}
@@ -3111,7 +3315,7 @@
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
} else {
- return createInvalid();
+ return createInvalid$1();
}
}
),
@@ -3122,7 +3326,7 @@
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
} else {
- return createInvalid();
+ return createInvalid$1();
}
}
);
@@ -3140,9 +3344,20 @@
if (!moments.length) {
return createLocal();
}
- res = moments[0];
- for (i = 1; i < moments.length; ++i) {
- if (!moments[i].isValid() || moments[i][fn](res)) {
+ for (i = 0; i < moments.length; ++i) {
+ if (isMoment(moments[i])) {
+ res = moments[i];
+ break;
+ }
+ }
+ if (!res) {
+ return createInvalid$1();
+ }
+ for (++i; i < moments.length; ++i) {
+ if (
+ isMoment(moments[i]) &&
+ (!moments[i].isValid() || moments[i][fn](res))
+ ) {
res = moments[i];
}
}
@@ -3213,7 +3428,7 @@
return this._isValid;
}
- function createInvalid$1() {
+ function createInvalid() {
return createDuration(NaN);
}
@@ -3272,8 +3487,7 @@
i;
for (i = 0; i < len; i++) {
if (
- (dontConvert && array1[i] !== array2[i]) ||
- (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
+ (toInt(array1[i]) !== toInt(array2[i]))
) {
diffs++;
}
@@ -3308,8 +3522,12 @@
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
+ var offset = offsetFromString(matchShortOffset, input);
config._useUTC = true;
- config._tzm = offsetFromString(matchShortOffset, input);
+ config._tzm = offset;
+ if (offset === null) {
+ getParsingFlags(config).invalidOffset = input;
+ }
});
// HELPERS
@@ -3333,6 +3551,13 @@
parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
minutes = +(parts[1] * 60) + toInt(parts[2]);
+ if (
+ toInt(parts[2]) > 59 ||
+ (parts[0] === '+' ? minutes > 14 * 60 : minutes > 12 * 60)
+ ) {
+ return null;
+ }
+
return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
}
@@ -3403,7 +3628,7 @@
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
- addSubtract(
+ addSubtract$1(
this,
createDuration(input - offset, 'm'),
1,
@@ -3596,7 +3821,7 @@
}
createDuration.fn = Duration.prototype;
- createDuration.invalid = createInvalid$1;
+ createDuration.invalid = createInvalid;
function parseIso(inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
@@ -3660,12 +3885,12 @@
}
dur = createDuration(val, period);
- addSubtract(this, dur, direction);
+ addSubtract$1(this, dur, direction);
return this;
};
}
- function addSubtract(mom, duration, isAdding, updateOffset) {
+ function addSubtract$1(mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
days = absRound(duration._days),
months = absRound(duration._months);
@@ -3678,10 +3903,10 @@
updateOffset = updateOffset == null ? true : updateOffset;
if (months) {
- setMonth(mom, get(mom, 'Month') + months * isAdding);
+ setMonth(mom, get$2(mom, 'Month') + months * isAdding);
}
if (days) {
- set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
+ set$1(mom, 'Date', get$2(mom, 'Date') + days * isAdding);
}
if (milliseconds) {
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
@@ -3691,8 +3916,8 @@
}
}
- var add = createAdder(1, 'add'),
- subtract = createAdder(-1, 'subtract');
+ var add$1 = createAdder(1, 'add'),
+ subtract$1 = createAdder(-1, 'subtract');
function isString(input) {
return typeof input === 'string' || input instanceof String;
@@ -3804,7 +4029,7 @@
: 'sameElse';
}
- function calendar$1(time, formats) {
+ function calendar(time, formats) {
// Support for single parameter, formats only overload to the calendar function
if (arguments.length === 1) {
if (!arguments[0]) {
@@ -3834,7 +4059,7 @@
);
}
- function clone() {
+ function clone$1() {
return new Moment(this);
}
@@ -3990,7 +4215,7 @@
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
- function toISOString(keepOffset) {
+ function toISOString$1(keepOffset) {
if (!this.isValid()) {
return null;
}
@@ -4130,7 +4355,7 @@
MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
// actual modulo - handles negative numbers (for dates before 1970):
- function mod$1(dividend, divisor) {
+ function mod(dividend, divisor) {
return ((dividend % divisor) + divisor) % divisor;
}
@@ -4197,18 +4422,18 @@
break;
case 'hour':
time = this._d.valueOf();
- time -= mod$1(
+ time -= mod(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
);
break;
case 'minute':
time = this._d.valueOf();
- time -= mod$1(time, MS_PER_MINUTE);
+ time -= mod(time, MS_PER_MINUTE);
break;
case 'second':
time = this._d.valueOf();
- time -= mod$1(time, MS_PER_SECOND);
+ time -= mod(time, MS_PER_SECOND);
break;
}
@@ -4265,7 +4490,7 @@
time = this._d.valueOf();
time +=
MS_PER_HOUR -
- mod$1(
+ mod(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
) -
@@ -4273,11 +4498,11 @@
break;
case 'minute':
time = this._d.valueOf();
- time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
+ time += MS_PER_MINUTE - mod(time, MS_PER_MINUTE) - 1;
break;
case 'second':
time = this._d.valueOf();
- time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
+ time += MS_PER_SECOND - mod(time, MS_PER_SECOND) - 1;
break;
}
@@ -4286,7 +4511,7 @@
return this;
}
- function valueOf() {
+ function valueOf$1() {
return this._d.valueOf() - (this._offset || 0) * 60000;
}
@@ -4329,8 +4554,8 @@
return this.isValid() ? this.toISOString() : null;
}
- function isValid$2() {
- return isValid(this);
+ function isValid() {
+ return isValid$2(this);
}
function parsingFlags() {
@@ -4471,7 +4696,7 @@
}
function localeErasConvertYear(era, year) {
- var dir = era.since <= era.until ? +1 : -1;
+ var dir = era.since <= era.until ? 1 : -1;
if (year === undefined) {
return hooks(era.since).year();
} else {
@@ -4546,7 +4771,7 @@
val,
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
- dir = eras[i].since <= eras[i].until ? +1 : -1;
+ dir = eras[i].since <= eras[i].until ? 1 : -1;
// truncate time
val = this.clone().startOf('day').valueOf();
@@ -4905,106 +5130,106 @@
return this._isUTC ? 'Coordinated Universal Time' : '';
}
- var proto = Moment.prototype;
+ var proto$2 = Moment.prototype;
- proto.add = add;
- proto.calendar = calendar$1;
- proto.clone = clone;
- proto.diff = diff;
- proto.endOf = endOf;
- proto.format = format;
- proto.from = from;
- proto.fromNow = fromNow;
- proto.to = to;
- proto.toNow = toNow;
- proto.get = stringGet;
- proto.invalidAt = invalidAt;
- proto.isAfter = isAfter;
- proto.isBefore = isBefore;
- proto.isBetween = isBetween;
- proto.isSame = isSame;
- proto.isSameOrAfter = isSameOrAfter;
- proto.isSameOrBefore = isSameOrBefore;
- proto.isValid = isValid$2;
- proto.lang = lang;
- proto.locale = locale;
- proto.localeData = localeData;
- proto.max = prototypeMax;
- proto.min = prototypeMin;
- proto.parsingFlags = parsingFlags;
- proto.set = stringSet;
- proto.startOf = startOf;
- proto.subtract = subtract;
- proto.toArray = toArray;
- proto.toObject = toObject;
- proto.toDate = toDate;
- proto.toISOString = toISOString;
- proto.inspect = inspect;
+ proto$2.add = add$1;
+ proto$2.calendar = calendar;
+ proto$2.clone = clone$1;
+ proto$2.diff = diff;
+ proto$2.endOf = endOf;
+ proto$2.format = format;
+ proto$2.from = from;
+ proto$2.fromNow = fromNow;
+ proto$2.to = to;
+ proto$2.toNow = toNow;
+ proto$2.get = stringGet;
+ proto$2.invalidAt = invalidAt;
+ proto$2.isAfter = isAfter;
+ proto$2.isBefore = isBefore;
+ proto$2.isBetween = isBetween;
+ proto$2.isSame = isSame;
+ proto$2.isSameOrAfter = isSameOrAfter;
+ proto$2.isSameOrBefore = isSameOrBefore;
+ proto$2.isValid = isValid;
+ proto$2.lang = lang;
+ proto$2.locale = locale;
+ proto$2.localeData = localeData;
+ proto$2.max = prototypeMax;
+ proto$2.min = prototypeMin;
+ proto$2.parsingFlags = parsingFlags;
+ proto$2.set = stringSet;
+ proto$2.startOf = startOf;
+ proto$2.subtract = subtract$1;
+ proto$2.toArray = toArray;
+ proto$2.toObject = toObject;
+ proto$2.toDate = toDate;
+ proto$2.toISOString = toISOString$1;
+ proto$2.inspect = inspect;
if (typeof Symbol !== 'undefined' && Symbol.for != null) {
- proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
+ proto$2[Symbol.for('nodejs.util.inspect.custom')] = function () {
return 'Moment<' + this.format() + '>';
};
}
- proto.toJSON = toJSON;
- proto.toString = toString;
- proto.unix = unix;
- proto.valueOf = valueOf;
- proto.creationData = creationData;
- proto.eraName = getEraName;
- proto.eraNarrow = getEraNarrow;
- proto.eraAbbr = getEraAbbr;
- proto.eraYear = getEraYear;
- proto.year = getSetYear;
- proto.isLeapYear = getIsLeapYear;
- proto.weekYear = getSetWeekYear;
- proto.isoWeekYear = getSetISOWeekYear;
- proto.quarter = proto.quarters = getSetQuarter;
- proto.month = getSetMonth;
- proto.daysInMonth = getDaysInMonth;
- proto.week = proto.weeks = getSetWeek;
- proto.isoWeek = proto.isoWeeks = getSetISOWeek;
- proto.weeksInYear = getWeeksInYear;
- proto.weeksInWeekYear = getWeeksInWeekYear;
- proto.isoWeeksInYear = getISOWeeksInYear;
- proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
- proto.date = getSetDayOfMonth;
- proto.day = proto.days = getSetDayOfWeek;
- proto.weekday = getSetLocaleDayOfWeek;
- proto.isoWeekday = getSetISODayOfWeek;
- proto.dayOfYear = getSetDayOfYear;
- proto.hour = proto.hours = getSetHour;
- proto.minute = proto.minutes = getSetMinute;
- proto.second = proto.seconds = getSetSecond;
- proto.millisecond = proto.milliseconds = getSetMillisecond;
- proto.utcOffset = getSetOffset;
- proto.utc = setOffsetToUTC;
- proto.local = setOffsetToLocal;
- proto.parseZone = setOffsetToParsedOffset;
- proto.hasAlignedHourOffset = hasAlignedHourOffset;
- proto.isDST = isDaylightSavingTime;
- proto.isLocal = isLocal;
- proto.isUtcOffset = isUtcOffset;
- proto.isUtc = isUtc;
- proto.isUTC = isUtc;
- proto.zoneAbbr = getZoneAbbr;
- proto.zoneName = getZoneName;
- proto.dates = deprecate(
+ proto$2.toJSON = toJSON;
+ proto$2.toString = toString;
+ proto$2.unix = unix;
+ proto$2.valueOf = valueOf$1;
+ proto$2.creationData = creationData;
+ proto$2.eraName = getEraName;
+ proto$2.eraNarrow = getEraNarrow;
+ proto$2.eraAbbr = getEraAbbr;
+ proto$2.eraYear = getEraYear;
+ proto$2.year = getSetYear;
+ proto$2.isLeapYear = getIsLeapYear;
+ proto$2.weekYear = getSetWeekYear;
+ proto$2.isoWeekYear = getSetISOWeekYear;
+ proto$2.quarter = proto$2.quarters = getSetQuarter;
+ proto$2.month = getSetMonth;
+ proto$2.daysInMonth = getDaysInMonth;
+ proto$2.week = proto$2.weeks = getSetWeek;
+ proto$2.isoWeek = proto$2.isoWeeks = getSetISOWeek;
+ proto$2.weeksInYear = getWeeksInYear;
+ proto$2.weeksInWeekYear = getWeeksInWeekYear;
+ proto$2.isoWeeksInYear = getISOWeeksInYear;
+ proto$2.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
+ proto$2.date = getSetDayOfMonth;
+ proto$2.day = proto$2.days = getSetDayOfWeek;
+ proto$2.weekday = getSetLocaleDayOfWeek;
+ proto$2.isoWeekday = getSetISODayOfWeek;
+ proto$2.dayOfYear = getSetDayOfYear;
+ proto$2.hour = proto$2.hours = getSetHour;
+ proto$2.minute = proto$2.minutes = getSetMinute;
+ proto$2.second = proto$2.seconds = getSetSecond;
+ proto$2.millisecond = proto$2.milliseconds = getSetMillisecond;
+ proto$2.utcOffset = getSetOffset;
+ proto$2.utc = setOffsetToUTC;
+ proto$2.local = setOffsetToLocal;
+ proto$2.parseZone = setOffsetToParsedOffset;
+ proto$2.hasAlignedHourOffset = hasAlignedHourOffset;
+ proto$2.isDST = isDaylightSavingTime;
+ proto$2.isLocal = isLocal;
+ proto$2.isUtcOffset = isUtcOffset;
+ proto$2.isUtc = isUtc;
+ proto$2.isUTC = isUtc;
+ proto$2.zoneAbbr = getZoneAbbr;
+ proto$2.zoneName = getZoneName;
+ proto$2.dates = deprecate(
'dates accessor is deprecated. Use date instead.',
getSetDayOfMonth
);
- proto.months = deprecate(
+ proto$2.months = deprecate(
'months accessor is deprecated. Use month instead',
getSetMonth
);
- proto.years = deprecate(
+ proto$2.years = deprecate(
'years accessor is deprecated. Use year instead',
getSetYear
);
- proto.zone = deprecate(
+ proto$2.zone = deprecate(
'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
getSetZone
);
- proto.isDSTShifted = deprecate(
+ proto$2.isDSTShifted = deprecate(
'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
isDaylightSavingTimeShifted
);
@@ -5023,13 +5248,13 @@
var proto$1 = Locale.prototype;
- proto$1.calendar = calendar;
+ proto$1.calendar = calendar$1;
proto$1.longDateFormat = longDateFormat;
proto$1.invalidDate = invalidDate;
proto$1.ordinal = ordinal;
proto$1.preparse = preParsePostFormat;
proto$1.postformat = preParsePostFormat;
- proto$1.relativeTime = relativeTime;
+ proto$1.relativeTime = relativeTime$1;
proto$1.pastFuture = pastFuture;
proto$1.set = set;
proto$1.eras = localeEras;
@@ -5199,7 +5424,7 @@
var mathAbs = Math.abs;
- function abs() {
+ function abs$1() {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
@@ -5216,7 +5441,7 @@
return this;
}
- function addSubtract$1(duration, input, value, direction) {
+ function addSubtract(duration, input, value, direction) {
var other = createDuration(input, value);
duration._milliseconds += direction * other._milliseconds;
@@ -5227,13 +5452,13 @@
}
// supports only 2.0-style add(1, 's') or add(duration)
- function add$1(input, value) {
- return addSubtract$1(this, input, value, 1);
+ function add(input, value) {
+ return addSubtract(this, input, value, 1);
}
// supports only 2.0-style subtract(1, 's') or subtract(duration)
- function subtract$1(input, value) {
- return addSubtract$1(this, input, value, -1);
+ function subtract(input, value) {
+ return addSubtract(this, input, value, -1);
}
function absCeil(number) {
@@ -5257,12 +5482,10 @@
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
- if (
- !(
- (milliseconds >= 0 && days >= 0 && months >= 0) ||
- (milliseconds <= 0 && days <= 0 && months <= 0)
- )
- ) {
+ if (!(
+ (milliseconds >= 0 && days >= 0 && months >= 0) ||
+ (milliseconds <= 0 && days <= 0 && months <= 0)
+ )) {
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
days = 0;
months = 0;
@@ -5369,13 +5592,13 @@
asMonths = makeAs('M'),
asQuarters = makeAs('Q'),
asYears = makeAs('y'),
- valueOf$1 = asMilliseconds;
+ valueOf = asMilliseconds;
- function clone$1() {
+ function clone() {
return createDuration(this);
}
- function get$2(units) {
+ function get(units) {
units = normalizeUnits(units);
return this.isValid() ? this[units + 's']() : NaN;
}
@@ -5411,10 +5634,16 @@
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
- return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+ return relativeTimeWithoutPostformat.call(
+ locale,
+ number || 1,
+ !!withoutSuffix,
+ string,
+ isFuture
+ );
}
- function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
+ function relativeTime(posNegDuration, withoutSuffix, thresholds, locale) {
var duration = createDuration(posNegDuration).abs(),
seconds = round(duration.as('s')),
minutes = round(duration.as('m')),
@@ -5495,29 +5724,29 @@
withSuffix = argWithSuffix;
}
if (typeof argThresholds === 'object') {
- th = Object.assign({}, thresholds, argThresholds);
+ th = extend(extend({}, thresholds), argThresholds || {});
if (argThresholds.s != null && argThresholds.ss == null) {
th.ss = argThresholds.s - 1;
}
}
locale = this.localeData();
- output = relativeTime$1(this, !withSuffix, th, locale);
+ output = relativeTime(this, !withSuffix, th, locale);
if (withSuffix) {
- output = locale.pastFuture(+this, output);
+ output = pastFutureWithoutPostformat.call(locale, +this, output);
}
return locale.postformat(output);
}
- var abs$1 = Math.abs;
+ var abs = Math.abs;
function sign(x) {
return (x > 0) - (x < 0) || +x;
}
- function toISOString$1() {
+ function toISOString() {
// for ISO strings we do not use the normal bubbling rules:
// * milliseconds bubble up until they become hours
// * days do not bubble at all
@@ -5529,9 +5758,9 @@
return this.localeData().invalidDate();
}
- var seconds = abs$1(this._milliseconds) / 1000,
- days = abs$1(this._days),
- months = abs$1(this._months),
+ var seconds = abs(this._milliseconds) / 1000,
+ days = abs(this._days),
+ months = abs(this._months),
minutes,
hours,
years,
@@ -5579,46 +5808,46 @@
);
}
- var proto$2 = Duration.prototype;
+ var proto = Duration.prototype;
- proto$2.isValid = isValid$1;
- proto$2.abs = abs;
- proto$2.add = add$1;
- proto$2.subtract = subtract$1;
- proto$2.as = as;
- proto$2.asMilliseconds = asMilliseconds;
- proto$2.asSeconds = asSeconds;
- proto$2.asMinutes = asMinutes;
- proto$2.asHours = asHours;
- proto$2.asDays = asDays;
- proto$2.asWeeks = asWeeks;
- proto$2.asMonths = asMonths;
- proto$2.asQuarters = asQuarters;
- proto$2.asYears = asYears;
- proto$2.valueOf = valueOf$1;
- proto$2._bubble = bubble;
- proto$2.clone = clone$1;
- proto$2.get = get$2;
- proto$2.milliseconds = milliseconds;
- proto$2.seconds = seconds;
- proto$2.minutes = minutes;
- proto$2.hours = hours;
- proto$2.days = days;
- proto$2.weeks = weeks;
- proto$2.months = months;
- proto$2.years = years;
- proto$2.humanize = humanize;
- proto$2.toISOString = toISOString$1;
- proto$2.toString = toISOString$1;
- proto$2.toJSON = toISOString$1;
- proto$2.locale = locale;
- proto$2.localeData = localeData;
+ proto.isValid = isValid$1;
+ proto.abs = abs$1;
+ proto.add = add;
+ proto.subtract = subtract;
+ proto.as = as;
+ proto.asMilliseconds = asMilliseconds;
+ proto.asSeconds = asSeconds;
+ proto.asMinutes = asMinutes;
+ proto.asHours = asHours;
+ proto.asDays = asDays;
+ proto.asWeeks = asWeeks;
+ proto.asMonths = asMonths;
+ proto.asQuarters = asQuarters;
+ proto.asYears = asYears;
+ proto.valueOf = valueOf;
+ proto._bubble = bubble;
+ proto.clone = clone;
+ proto.get = get;
+ proto.milliseconds = milliseconds;
+ proto.seconds = seconds;
+ proto.minutes = minutes;
+ proto.hours = hours;
+ proto.days = days;
+ proto.weeks = weeks;
+ proto.months = months;
+ proto.years = years;
+ proto.humanize = humanize;
+ proto.toISOString = toISOString;
+ proto.toString = toISOString;
+ proto.toJSON = toISOString;
+ proto.locale = locale;
+ proto.localeData = localeData;
- proto$2.toIsoString = deprecate(
+ proto.toIsoString = deprecate(
'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
- toISOString$1
+ toISOString
);
- proto$2.lang = lang;
+ proto.lang = lang;
// FORMATTING
@@ -5638,11 +5867,11 @@
//! moment.js
- hooks.version = '2.30.1';
+ hooks.version = '2.31.0';
setHookCallback(createLocal);
- hooks.fn = proto;
+ hooks.fn = proto$2;
hooks.min = min;
hooks.max = max;
hooks.now = now;
@@ -5651,7 +5880,7 @@
hooks.months = listMonths;
hooks.isDate = isDate;
hooks.locale = getSetGlobalLocale;
- hooks.invalid = createInvalid;
+ hooks.invalid = createInvalid$1;
hooks.duration = createDuration;
hooks.isMoment = isMoment;
hooks.weekdays = listWeekdays;
@@ -5668,7 +5897,7 @@
hooks.relativeTimeRounding = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat = getCalendarFormat;
- hooks.prototype = proto;
+ hooks.prototype = proto$2;
// currently HTML5 input type only supports 24-hour formats
hooks.HTML5_FMT = {