update moment.js to version 2.13
This commit is contained in:
parent
1cc816f662
commit
852b2659e9
@ -1,6 +1,27 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
### 2.13.0 [See full changelog](https://gist.github.com/ichernev/0132fcf5b61f7fc140b0bb0090480d49)
|
||||||
|
|
||||||
|
## Enhancements:
|
||||||
|
* [#2982](https://github.com/moment/moment/pull/2982) Add 'date' as alias to 'day' for startOf() and endOf().
|
||||||
|
* [#2955](https://github.com/moment/moment/pull/2955) Add parsing negative components in durations when ISO 8601
|
||||||
|
* [#2991](https://github.com/moment/moment/pull/2991) isBetween support for both open and closed intervals
|
||||||
|
* [#3105](https://github.com/moment/moment/pull/3105) Add localeSorted argument to weekday listers
|
||||||
|
* [#3102](https://github.com/moment/moment/pull/3102) Add k and kk formatting tokens
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
* [#3109](https://github.com/moment/moment/pull/3109) Fix [#1756](https://github.com/moment/moment/issues/1756) Resolved thread-safe issue on server side.
|
||||||
|
* [#3078](https://github.com/moment/moment/pull/3078) Fix parsing for months/weekdays with weird characters
|
||||||
|
* [#3098](https://github.com/moment/moment/pull/3098) Use Z suffix when in UTC mode ([#3020](https://github.com/moment/moment/issues/3020))
|
||||||
|
* [#2995](https://github.com/moment/moment/pull/2995) Fix floating point rounding errors in durations
|
||||||
|
* [#3059](https://github.com/moment/moment/pull/3059) fix bug where diff returns -0 in month-related diffs
|
||||||
|
* [#3045](https://github.com/moment/moment/pull/3045) Fix mistaking any input for 'a' token
|
||||||
|
* [#2877](https://github.com/moment/moment/pull/2877) Use explicit .valueOf() calls instead of coercion
|
||||||
|
* [#3036](https://github.com/moment/moment/pull/3036) Year setter should keep time when DST changes
|
||||||
|
|
||||||
|
Plus 3 new locales and locale fixes.
|
||||||
|
|
||||||
### 2.12.0 [See full changelog](https://gist.github.com/ichernev/6e5bfdf8d6522fc4ac73)
|
### 2.12.0 [See full changelog](https://gist.github.com/ichernev/6e5bfdf8d6522fc4ac73)
|
||||||
|
|
||||||
## Enhancements:
|
## Enhancements:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
|
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
|
||||||
|
|
||||||
## [Documentation](http://momentjs.com/docs/)
|
**[Documentation](http://momentjs.com/docs/)**
|
||||||
|
|
||||||
## Port to ECMAScript 6 (version 2.10.0)
|
## Port to ECMAScript 6 (version 2.10.0)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! moment.js
|
//! moment.js
|
||||||
//! version : 2.12.0
|
//! version : 2.13.0
|
||||||
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
||||||
//! license : MIT
|
//! license : MIT
|
||||||
//! momentjs.com
|
//! momentjs.com
|
||||||
@ -76,7 +76,9 @@
|
|||||||
invalidMonth : null,
|
invalidMonth : null,
|
||||||
invalidFormat : false,
|
invalidFormat : false,
|
||||||
userInvalidated : false,
|
userInvalidated : false,
|
||||||
iso : false
|
iso : false,
|
||||||
|
parsedDateParts : [],
|
||||||
|
meridiem : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +89,30 @@
|
|||||||
return m._pf;
|
return m._pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var some;
|
||||||
|
if (Array.prototype.some) {
|
||||||
|
some = Array.prototype.some;
|
||||||
|
} else {
|
||||||
|
some = function (fun) {
|
||||||
|
var t = Object(this);
|
||||||
|
var len = t.length >>> 0;
|
||||||
|
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
if (i in t && fun.call(this, t[i], i, t)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function valid__isValid(m) {
|
function valid__isValid(m) {
|
||||||
if (m._isValid == null) {
|
if (m._isValid == null) {
|
||||||
var flags = getParsingFlags(m);
|
var flags = getParsingFlags(m);
|
||||||
|
var parsedParts = some.call(flags.parsedDateParts, function (i) {
|
||||||
|
return i != null;
|
||||||
|
});
|
||||||
m._isValid = !isNaN(m._d.getTime()) &&
|
m._isValid = !isNaN(m._d.getTime()) &&
|
||||||
flags.overflow < 0 &&
|
flags.overflow < 0 &&
|
||||||
!flags.empty &&
|
!flags.empty &&
|
||||||
@ -97,7 +120,8 @@
|
|||||||
!flags.invalidWeekday &&
|
!flags.invalidWeekday &&
|
||||||
!flags.nullInput &&
|
!flags.nullInput &&
|
||||||
!flags.invalidFormat &&
|
!flags.invalidFormat &&
|
||||||
!flags.userInvalidated;
|
!flags.userInvalidated &&
|
||||||
|
(!flags.meridiem || (flags.meridiem && parsedParts));
|
||||||
|
|
||||||
if (m._strict) {
|
if (m._strict) {
|
||||||
m._isValid = m._isValid &&
|
m._isValid = m._isValid &&
|
||||||
@ -240,6 +264,9 @@
|
|||||||
var firstTime = true;
|
var firstTime = true;
|
||||||
|
|
||||||
return extend(function () {
|
return extend(function () {
|
||||||
|
if (utils_hooks__hooks.deprecationHandler != null) {
|
||||||
|
utils_hooks__hooks.deprecationHandler(null, msg);
|
||||||
|
}
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
|
warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
@ -251,6 +278,9 @@
|
|||||||
var deprecations = {};
|
var deprecations = {};
|
||||||
|
|
||||||
function deprecateSimple(name, msg) {
|
function deprecateSimple(name, msg) {
|
||||||
|
if (utils_hooks__hooks.deprecationHandler != null) {
|
||||||
|
utils_hooks__hooks.deprecationHandler(name, msg);
|
||||||
|
}
|
||||||
if (!deprecations[name]) {
|
if (!deprecations[name]) {
|
||||||
warn(msg);
|
warn(msg);
|
||||||
deprecations[name] = true;
|
deprecations[name] = true;
|
||||||
@ -258,6 +288,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils_hooks__hooks.suppressDeprecationWarnings = false;
|
utils_hooks__hooks.suppressDeprecationWarnings = false;
|
||||||
|
utils_hooks__hooks.deprecationHandler = null;
|
||||||
|
|
||||||
function isFunction(input) {
|
function isFunction(input) {
|
||||||
return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
|
||||||
@ -307,6 +338,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// internal storage for locale config files
|
// internal storage for locale config files
|
||||||
var locales = {};
|
var locales = {};
|
||||||
var globalLocale;
|
var globalLocale;
|
||||||
@ -461,7 +508,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function locale_locales__listLocales() {
|
function locale_locales__listLocales() {
|
||||||
return Object.keys(locales);
|
return keys(locales);
|
||||||
}
|
}
|
||||||
|
|
||||||
var aliases = {};
|
var aliases = {};
|
||||||
@ -540,7 +587,7 @@
|
|||||||
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
|
||||||
|
|
||||||
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
||||||
|
|
||||||
@ -593,7 +640,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return function (mom) {
|
return function (mom) {
|
||||||
var output = '';
|
var output = '', i;
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
|
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
|
||||||
}
|
}
|
||||||
@ -722,6 +769,23 @@
|
|||||||
var WEEK = 7;
|
var WEEK = 7;
|
||||||
var WEEKDAY = 8;
|
var WEEKDAY = 8;
|
||||||
|
|
||||||
|
var indexOf;
|
||||||
|
|
||||||
|
if (Array.prototype.indexOf) {
|
||||||
|
indexOf = Array.prototype.indexOf;
|
||||||
|
} else {
|
||||||
|
indexOf = function (o) {
|
||||||
|
// I know
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < this.length; ++i) {
|
||||||
|
if (this[i] === o) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function daysInMonth(year, month) {
|
function daysInMonth(year, month) {
|
||||||
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
||||||
}
|
}
|
||||||
@ -784,15 +848,63 @@
|
|||||||
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function units_month__handleStrictParse(monthName, format, strict) {
|
||||||
|
var i, ii, mom, llc = monthName.toLocaleLowerCase();
|
||||||
|
if (!this._monthsParse) {
|
||||||
|
// this is not used
|
||||||
|
this._monthsParse = [];
|
||||||
|
this._longMonthsParse = [];
|
||||||
|
this._shortMonthsParse = [];
|
||||||
|
for (i = 0; i < 12; ++i) {
|
||||||
|
mom = create_utc__createUTC([2000, i]);
|
||||||
|
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
|
||||||
|
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strict) {
|
||||||
|
if (format === 'MMM') {
|
||||||
|
ii = indexOf.call(this._shortMonthsParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else {
|
||||||
|
ii = indexOf.call(this._longMonthsParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (format === 'MMM') {
|
||||||
|
ii = indexOf.call(this._shortMonthsParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._longMonthsParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else {
|
||||||
|
ii = indexOf.call(this._longMonthsParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._shortMonthsParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function localeMonthsParse (monthName, format, strict) {
|
function localeMonthsParse (monthName, format, strict) {
|
||||||
var i, mom, regex;
|
var i, mom, regex;
|
||||||
|
|
||||||
|
if (this._monthsParseExact) {
|
||||||
|
return units_month__handleStrictParse.call(this, monthName, format, strict);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this._monthsParse) {
|
if (!this._monthsParse) {
|
||||||
this._monthsParse = [];
|
this._monthsParse = [];
|
||||||
this._longMonthsParse = [];
|
this._longMonthsParse = [];
|
||||||
this._shortMonthsParse = [];
|
this._shortMonthsParse = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add sorting
|
||||||
|
// Sorting makes sure if one month (or abbr) is a prefix of another
|
||||||
|
// see sorting in computeMonthsParse
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
// make the regex if we don't have it already
|
// make the regex if we don't have it already
|
||||||
mom = create_utc__createUTC([2000, i]);
|
mom = create_utc__createUTC([2000, i]);
|
||||||
@ -918,8 +1030,8 @@
|
|||||||
|
|
||||||
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
|
||||||
this._monthsShortRegex = this._monthsRegex;
|
this._monthsShortRegex = this._monthsRegex;
|
||||||
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')$', 'i');
|
this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
|
||||||
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')$', 'i');
|
this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkOverflow (m) {
|
function checkOverflow (m) {
|
||||||
@ -1146,7 +1258,7 @@
|
|||||||
|
|
||||||
// MOMENTS
|
// MOMENTS
|
||||||
|
|
||||||
var getSetYear = makeGetSet('FullYear', false);
|
var getSetYear = makeGetSet('FullYear', true);
|
||||||
|
|
||||||
function getIsLeapYear () {
|
function getIsLeapYear () {
|
||||||
return isLeapYear(this.year());
|
return isLeapYear(this.year());
|
||||||
@ -1415,6 +1527,9 @@
|
|||||||
config._a[HOUR] > 0) {
|
config._a[HOUR] > 0) {
|
||||||
getParsingFlags(config).bigHour = undefined;
|
getParsingFlags(config).bigHour = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getParsingFlags(config).parsedDateParts = config._a.slice(0);
|
||||||
|
getParsingFlags(config).meridiem = config._meridiem;
|
||||||
// handle meridiem
|
// handle meridiem
|
||||||
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
||||||
|
|
||||||
@ -1555,7 +1670,7 @@
|
|||||||
if (input === undefined) {
|
if (input === undefined) {
|
||||||
config._d = new Date(utils_hooks__hooks.now());
|
config._d = new Date(utils_hooks__hooks.now());
|
||||||
} else if (isDate(input)) {
|
} else if (isDate(input)) {
|
||||||
config._d = new Date(+input);
|
config._d = new Date(input.valueOf());
|
||||||
} else if (typeof input === 'string') {
|
} else if (typeof input === 'string') {
|
||||||
configFromString(config);
|
configFromString(config);
|
||||||
} else if (isArray(input)) {
|
} else if (isArray(input)) {
|
||||||
@ -1675,7 +1790,7 @@
|
|||||||
this._milliseconds = +milliseconds +
|
this._milliseconds = +milliseconds +
|
||||||
seconds * 1e3 + // 1000
|
seconds * 1e3 + // 1000
|
||||||
minutes * 6e4 + // 1000 * 60
|
minutes * 6e4 + // 1000 * 60
|
||||||
hours * 36e5; // 1000 * 60 * 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
|
// Because of dateAddRemove treats 24 hours as different from a
|
||||||
// day when working around DST, we need to store them separately
|
// day when working around DST, we need to store them separately
|
||||||
this._days = +days +
|
this._days = +days +
|
||||||
@ -1745,9 +1860,9 @@
|
|||||||
var res, diff;
|
var res, diff;
|
||||||
if (model._isUTC) {
|
if (model._isUTC) {
|
||||||
res = model.clone();
|
res = model.clone();
|
||||||
diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
|
diff = (isMoment(input) || isDate(input) ? input.valueOf() : local__createLocal(input).valueOf()) - res.valueOf();
|
||||||
// Use low-level api, because this fn is low-level api.
|
// Use low-level api, because this fn is low-level api.
|
||||||
res._d.setTime(+res._d + diff);
|
res._d.setTime(res._d.valueOf() + diff);
|
||||||
utils_hooks__hooks.updateOffset(res, false);
|
utils_hooks__hooks.updateOffset(res, false);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
@ -1908,7 +2023,7 @@
|
|||||||
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
|
// 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
|
// 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
|
// and further modified to allow for strings containing both week and day
|
||||||
var isoRegex = /^(-)?P(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)W)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?$/;
|
var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
|
||||||
|
|
||||||
function create__createDuration (input, key) {
|
function create__createDuration (input, key) {
|
||||||
var duration = input,
|
var duration = input,
|
||||||
@ -2052,7 +2167,7 @@
|
|||||||
updateOffset = updateOffset == null ? true : updateOffset;
|
updateOffset = updateOffset == null ? true : updateOffset;
|
||||||
|
|
||||||
if (milliseconds) {
|
if (milliseconds) {
|
||||||
mom._d.setTime(+mom._d + milliseconds * isAdding);
|
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
|
||||||
}
|
}
|
||||||
if (days) {
|
if (days) {
|
||||||
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
|
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
|
||||||
@ -2097,9 +2212,9 @@
|
|||||||
}
|
}
|
||||||
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
||||||
if (units === 'millisecond') {
|
if (units === 'millisecond') {
|
||||||
return +this > +localInput;
|
return this.valueOf() > localInput.valueOf();
|
||||||
} else {
|
} else {
|
||||||
return +localInput < +this.clone().startOf(units);
|
return localInput.valueOf() < this.clone().startOf(units).valueOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2110,14 +2225,16 @@
|
|||||||
}
|
}
|
||||||
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
|
||||||
if (units === 'millisecond') {
|
if (units === 'millisecond') {
|
||||||
return +this < +localInput;
|
return this.valueOf() < localInput.valueOf();
|
||||||
} else {
|
} else {
|
||||||
return +this.clone().endOf(units) < +localInput;
|
return this.clone().endOf(units).valueOf() < localInput.valueOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBetween (from, to, units) {
|
function isBetween (from, to, units, inclusivity) {
|
||||||
return this.isAfter(from, units) && this.isBefore(to, units);
|
inclusivity = inclusivity || '()';
|
||||||
|
return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
|
||||||
|
(inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSame (input, units) {
|
function isSame (input, units) {
|
||||||
@ -2128,10 +2245,10 @@
|
|||||||
}
|
}
|
||||||
units = normalizeUnits(units || 'millisecond');
|
units = normalizeUnits(units || 'millisecond');
|
||||||
if (units === 'millisecond') {
|
if (units === 'millisecond') {
|
||||||
return +this === +localInput;
|
return this.valueOf() === localInput.valueOf();
|
||||||
} else {
|
} else {
|
||||||
inputMs = +localInput;
|
inputMs = localInput.valueOf();
|
||||||
return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
|
return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2198,10 +2315,12 @@
|
|||||||
adjust = (b - anchor) / (anchor2 - anchor);
|
adjust = (b - anchor) / (anchor2 - anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -(wholeMonthDiff + adjust);
|
//check for negative zero, return zero if negative zero
|
||||||
|
return -(wholeMonthDiff + adjust) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
||||||
|
utils_hooks__hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
|
||||||
|
|
||||||
function toString () {
|
function toString () {
|
||||||
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
||||||
@ -2222,7 +2341,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function format (inputString) {
|
function format (inputString) {
|
||||||
var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
|
if (!inputString) {
|
||||||
|
inputString = this.isUtc() ? utils_hooks__hooks.defaultFormatUtc : utils_hooks__hooks.defaultFormat;
|
||||||
|
}
|
||||||
|
var output = formatMoment(this, inputString);
|
||||||
return this.localeData().postformat(output);
|
return this.localeData().postformat(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2301,6 +2423,7 @@
|
|||||||
case 'week':
|
case 'week':
|
||||||
case 'isoWeek':
|
case 'isoWeek':
|
||||||
case 'day':
|
case 'day':
|
||||||
|
case 'date':
|
||||||
this.hours(0);
|
this.hours(0);
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 'hour':
|
case 'hour':
|
||||||
@ -2334,19 +2457,25 @@
|
|||||||
if (units === undefined || units === 'millisecond') {
|
if (units === undefined || units === 'millisecond') {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'date' is an alias for 'day', so it should be considered as such.
|
||||||
|
if (units === 'date') {
|
||||||
|
units = 'day';
|
||||||
|
}
|
||||||
|
|
||||||
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
|
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
|
||||||
}
|
}
|
||||||
|
|
||||||
function to_type__valueOf () {
|
function to_type__valueOf () {
|
||||||
return +this._d - ((this._offset || 0) * 60000);
|
return this._d.valueOf() - ((this._offset || 0) * 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unix () {
|
function unix () {
|
||||||
return Math.floor(+this / 1000);
|
return Math.floor(this.valueOf() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toDate () {
|
function toDate () {
|
||||||
return this._offset ? new Date(+this) : this._d;
|
return this._offset ? new Date(this.valueOf()) : this._d;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toArray () {
|
function toArray () {
|
||||||
@ -2615,9 +2744,15 @@
|
|||||||
addRegexToken('d', match1to2);
|
addRegexToken('d', match1to2);
|
||||||
addRegexToken('e', match1to2);
|
addRegexToken('e', match1to2);
|
||||||
addRegexToken('E', match1to2);
|
addRegexToken('E', match1to2);
|
||||||
addRegexToken('dd', matchWord);
|
addRegexToken('dd', function (isStrict, locale) {
|
||||||
addRegexToken('ddd', matchWord);
|
return locale.weekdaysMinRegex(isStrict);
|
||||||
addRegexToken('dddd', matchWord);
|
});
|
||||||
|
addRegexToken('ddd', function (isStrict, locale) {
|
||||||
|
return locale.weekdaysShortRegex(isStrict);
|
||||||
|
});
|
||||||
|
addRegexToken('dddd', function (isStrict, locale) {
|
||||||
|
return locale.weekdaysRegex(isStrict);
|
||||||
|
});
|
||||||
|
|
||||||
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
|
||||||
var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
var weekday = config._locale.weekdaysParse(input, token, config._strict);
|
||||||
@ -2670,9 +2805,77 @@
|
|||||||
return this._weekdaysMin[m.day()];
|
return this._weekdaysMin[m.day()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function day_of_week__handleStrictParse(weekdayName, format, strict) {
|
||||||
|
var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
|
||||||
|
if (!this._weekdaysParse) {
|
||||||
|
this._weekdaysParse = [];
|
||||||
|
this._shortWeekdaysParse = [];
|
||||||
|
this._minWeekdaysParse = [];
|
||||||
|
|
||||||
|
for (i = 0; i < 7; ++i) {
|
||||||
|
mom = create_utc__createUTC([2000, 1]).day(i);
|
||||||
|
this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
|
||||||
|
this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
|
||||||
|
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strict) {
|
||||||
|
if (format === 'dddd') {
|
||||||
|
ii = indexOf.call(this._weekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else if (format === 'ddd') {
|
||||||
|
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else {
|
||||||
|
ii = indexOf.call(this._minWeekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (format === 'dddd') {
|
||||||
|
ii = indexOf.call(this._weekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._minWeekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else if (format === 'ddd') {
|
||||||
|
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._weekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._minWeekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
} else {
|
||||||
|
ii = indexOf.call(this._minWeekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._weekdaysParse, llc);
|
||||||
|
if (ii !== -1) {
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
ii = indexOf.call(this._shortWeekdaysParse, llc);
|
||||||
|
return ii !== -1 ? ii : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function localeWeekdaysParse (weekdayName, format, strict) {
|
function localeWeekdaysParse (weekdayName, format, strict) {
|
||||||
var i, mom, regex;
|
var i, mom, regex;
|
||||||
|
|
||||||
|
if (this._weekdaysParseExact) {
|
||||||
|
return day_of_week__handleStrictParse.call(this, weekdayName, format, strict);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this._weekdaysParse) {
|
if (!this._weekdaysParse) {
|
||||||
this._weekdaysParse = [];
|
this._weekdaysParse = [];
|
||||||
this._minWeekdaysParse = [];
|
this._minWeekdaysParse = [];
|
||||||
@ -2683,7 +2886,7 @@
|
|||||||
for (i = 0; i < 7; i++) {
|
for (i = 0; i < 7; i++) {
|
||||||
// make the regex if we don't have it already
|
// make the regex if we don't have it already
|
||||||
|
|
||||||
mom = local__createLocal([2000, 1]).day(i);
|
mom = create_utc__createUTC([2000, 1]).day(i);
|
||||||
if (strict && !this._fullWeekdaysParse[i]) {
|
if (strict && !this._fullWeekdaysParse[i]) {
|
||||||
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
|
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
|
||||||
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
|
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
|
||||||
@ -2739,6 +2942,99 @@
|
|||||||
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultWeekdaysRegex = matchWord;
|
||||||
|
function weekdaysRegex (isStrict) {
|
||||||
|
if (this._weekdaysParseExact) {
|
||||||
|
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
||||||
|
computeWeekdaysParse.call(this);
|
||||||
|
}
|
||||||
|
if (isStrict) {
|
||||||
|
return this._weekdaysStrictRegex;
|
||||||
|
} else {
|
||||||
|
return this._weekdaysRegex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return this._weekdaysStrictRegex && isStrict ?
|
||||||
|
this._weekdaysStrictRegex : this._weekdaysRegex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultWeekdaysShortRegex = matchWord;
|
||||||
|
function weekdaysShortRegex (isStrict) {
|
||||||
|
if (this._weekdaysParseExact) {
|
||||||
|
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
||||||
|
computeWeekdaysParse.call(this);
|
||||||
|
}
|
||||||
|
if (isStrict) {
|
||||||
|
return this._weekdaysShortStrictRegex;
|
||||||
|
} else {
|
||||||
|
return this._weekdaysShortRegex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return this._weekdaysShortStrictRegex && isStrict ?
|
||||||
|
this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultWeekdaysMinRegex = matchWord;
|
||||||
|
function weekdaysMinRegex (isStrict) {
|
||||||
|
if (this._weekdaysParseExact) {
|
||||||
|
if (!hasOwnProp(this, '_weekdaysRegex')) {
|
||||||
|
computeWeekdaysParse.call(this);
|
||||||
|
}
|
||||||
|
if (isStrict) {
|
||||||
|
return this._weekdaysMinStrictRegex;
|
||||||
|
} else {
|
||||||
|
return this._weekdaysMinRegex;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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 = create_utc__createUTC([2000, 1]).day(i);
|
||||||
|
minp = this.weekdaysMin(mom, '');
|
||||||
|
shortp = this.weekdaysShort(mom, '');
|
||||||
|
longp = 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);
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
shortPieces[i] = regexEscape(shortPieces[i]);
|
||||||
|
longPieces[i] = regexEscape(longPieces[i]);
|
||||||
|
mixedPieces[i] = regexEscape(mixedPieces[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
// FORMATTING
|
// FORMATTING
|
||||||
|
|
||||||
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
||||||
@ -2770,8 +3066,13 @@
|
|||||||
return this.hours() % 12 || 12;
|
return this.hours() % 12 || 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function kFormat() {
|
||||||
|
return this.hours() || 24;
|
||||||
|
}
|
||||||
|
|
||||||
addFormatToken('H', ['HH', 2], 0, 'hour');
|
addFormatToken('H', ['HH', 2], 0, 'hour');
|
||||||
addFormatToken('h', ['hh', 2], 0, hFormat);
|
addFormatToken('h', ['hh', 2], 0, hFormat);
|
||||||
|
addFormatToken('k', ['kk', 2], 0, kFormat);
|
||||||
|
|
||||||
addFormatToken('hmm', 0, 0, function () {
|
addFormatToken('hmm', 0, 0, function () {
|
||||||
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
|
||||||
@ -3232,6 +3533,13 @@
|
|||||||
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
|
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
|
||||||
prototype__proto.weekdaysParse = localeWeekdaysParse;
|
prototype__proto.weekdaysParse = localeWeekdaysParse;
|
||||||
|
|
||||||
|
prototype__proto._weekdaysRegex = defaultWeekdaysRegex;
|
||||||
|
prototype__proto.weekdaysRegex = weekdaysRegex;
|
||||||
|
prototype__proto._weekdaysShortRegex = defaultWeekdaysShortRegex;
|
||||||
|
prototype__proto.weekdaysShortRegex = weekdaysShortRegex;
|
||||||
|
prototype__proto._weekdaysMinRegex = defaultWeekdaysMinRegex;
|
||||||
|
prototype__proto.weekdaysMinRegex = weekdaysMinRegex;
|
||||||
|
|
||||||
// Hours
|
// Hours
|
||||||
prototype__proto.isPM = localeIsPM;
|
prototype__proto.isPM = localeIsPM;
|
||||||
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
|
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
|
||||||
@ -3243,7 +3551,7 @@
|
|||||||
return locale[field](utc, format);
|
return locale[field](utc, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
function list (format, index, field, count, setter) {
|
function listMonthsImpl (format, index, field) {
|
||||||
if (typeof format === 'number') {
|
if (typeof format === 'number') {
|
||||||
index = format;
|
index = format;
|
||||||
format = undefined;
|
format = undefined;
|
||||||
@ -3252,35 +3560,79 @@
|
|||||||
format = format || '';
|
format = format || '';
|
||||||
|
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
return lists__get(format, index, field, setter);
|
return lists__get(format, index, field, 'month');
|
||||||
}
|
}
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
var out = [];
|
var out = [];
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
out[i] = lists__get(format, i, field, setter);
|
out[i] = lists__get(format, i, field, 'month');
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ()
|
||||||
|
// (5)
|
||||||
|
// (fmt, 5)
|
||||||
|
// (fmt)
|
||||||
|
// (true)
|
||||||
|
// (true, 5)
|
||||||
|
// (true, fmt, 5)
|
||||||
|
// (true, fmt)
|
||||||
|
function listWeekdaysImpl (localeSorted, format, index, field) {
|
||||||
|
if (typeof localeSorted === 'boolean') {
|
||||||
|
if (typeof format === 'number') {
|
||||||
|
index = format;
|
||||||
|
format = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
format = format || '';
|
||||||
|
} else {
|
||||||
|
format = localeSorted;
|
||||||
|
index = format;
|
||||||
|
localeSorted = false;
|
||||||
|
|
||||||
|
if (typeof format === 'number') {
|
||||||
|
index = format;
|
||||||
|
format = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
format = format || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
var locale = locale_locales__getLocale(),
|
||||||
|
shift = localeSorted ? locale._week.dow : 0;
|
||||||
|
|
||||||
|
if (index != null) {
|
||||||
|
return lists__get(format, (index + shift) % 7, field, 'day');
|
||||||
|
}
|
||||||
|
|
||||||
|
var i;
|
||||||
|
var out = [];
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
out[i] = lists__get(format, (i + shift) % 7, field, 'day');
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lists__listMonths (format, index) {
|
function lists__listMonths (format, index) {
|
||||||
return list(format, index, 'months', 12, 'month');
|
return listMonthsImpl(format, index, 'months');
|
||||||
}
|
}
|
||||||
|
|
||||||
function lists__listMonthsShort (format, index) {
|
function lists__listMonthsShort (format, index) {
|
||||||
return list(format, index, 'monthsShort', 12, 'month');
|
return listMonthsImpl(format, index, 'monthsShort');
|
||||||
}
|
}
|
||||||
|
|
||||||
function lists__listWeekdays (format, index) {
|
function lists__listWeekdays (localeSorted, format, index) {
|
||||||
return list(format, index, 'weekdays', 7, 'day');
|
return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
|
||||||
}
|
}
|
||||||
|
|
||||||
function lists__listWeekdaysShort (format, index) {
|
function lists__listWeekdaysShort (localeSorted, format, index) {
|
||||||
return list(format, index, 'weekdaysShort', 7, 'day');
|
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
|
||||||
}
|
}
|
||||||
|
|
||||||
function lists__listWeekdaysMin (format, index) {
|
function lists__listWeekdaysMin (localeSorted, format, index) {
|
||||||
return list(format, index, 'weekdaysMin', 7, 'day');
|
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
|
||||||
}
|
}
|
||||||
|
|
||||||
locale_locales__getSetGlobalLocale('en', {
|
locale_locales__getSetGlobalLocale('en', {
|
||||||
@ -3651,7 +4003,7 @@
|
|||||||
// Side effect imports
|
// Side effect imports
|
||||||
|
|
||||||
|
|
||||||
utils_hooks__hooks.version = '2.12.0';
|
utils_hooks__hooks.version = '2.13.0';
|
||||||
|
|
||||||
setHookCallback(local__createLocal);
|
setHookCallback(local__createLocal);
|
||||||
|
|
||||||
|
6
library/moment/moment.min.js
vendored
6
library/moment/moment.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user