aboutsummaryrefslogtreecommitdiff
path: root/node_modules/moment/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/moment/src/lib')
-rw-r--r--node_modules/moment/src/lib/create/from-array.js6
-rw-r--r--node_modules/moment/src/lib/create/from-string.js2
-rw-r--r--node_modules/moment/src/lib/locale/locales.js29
-rw-r--r--node_modules/moment/src/lib/moment/format.js15
-rw-r--r--node_modules/moment/src/lib/parse/regex.js2
-rw-r--r--node_modules/moment/src/lib/units/day-of-month.js4
-rw-r--r--node_modules/moment/src/lib/units/day-of-week.js6
-rw-r--r--node_modules/moment/src/lib/units/hour.js2
8 files changed, 42 insertions, 24 deletions
diff --git a/node_modules/moment/src/lib/create/from-array.js b/node_modules/moment/src/lib/create/from-array.js
index 7626c455d..b5a0911de 100644
--- a/node_modules/moment/src/lib/create/from-array.js
+++ b/node_modules/moment/src/lib/create/from-array.js
@@ -21,7 +21,7 @@ function currentDateArray(config) {
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
export function configFromArray (config) {
- var i, date, input = [], currentDate, yearToUse;
+ var i, date, input = [], currentDate, expectedWeekday, yearToUse;
if (config._d) {
return;
@@ -71,6 +71,8 @@ export function configFromArray (config) {
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
+ expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
+
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
@@ -82,7 +84,7 @@ export function configFromArray (config) {
}
// check for mismatching day of week
- if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== config._d.getDay()) {
+ if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
getParsingFlags(config).weekdayMismatch = true;
}
}
diff --git a/node_modules/moment/src/lib/create/from-string.js b/node_modules/moment/src/lib/create/from-string.js
index 7c1052a3e..c5ad56bab 100644
--- a/node_modules/moment/src/lib/create/from-string.js
+++ b/node_modules/moment/src/lib/create/from-string.js
@@ -128,7 +128,7 @@ function untruncateYear(yearStr) {
function preprocessRFC2822(s) {
// Remove comments and folding whitespace and replace multiple-spaces with a single space
- return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
+ return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function checkWeekday(weekdayStr, parsedInput, config) {
diff --git a/node_modules/moment/src/lib/locale/locales.js b/node_modules/moment/src/lib/locale/locales.js
index 7d8fb26e0..af28bfe27 100644
--- a/node_modules/moment/src/lib/locale/locales.js
+++ b/node_modules/moment/src/lib/locale/locales.js
@@ -42,7 +42,7 @@ function chooseLocale(names) {
}
i++;
}
- return null;
+ return globalLocale;
}
function loadLocale(name) {
@@ -77,6 +77,12 @@ export function getSetGlobalLocale (key, values) {
// moment.duration._locale = moment._locale = data;
globalLocale = data;
}
+ else {
+ if ((typeof console !== 'undefined') && console.warn) {
+ //warn user if arguments are passed but the locale could not be set
+ console.warn('Locale ' + key + ' not found. Did you forget to load it?');
+ }
+ }
}
return globalLocale._abbr;
@@ -84,7 +90,7 @@ export function getSetGlobalLocale (key, values) {
export function defineLocale (name, config) {
if (config !== null) {
- var parentConfig = baseConfig;
+ var locale, parentConfig = baseConfig;
config.abbr = name;
if (locales[name] != null) {
deprecateSimple('defineLocaleOverride',
@@ -97,14 +103,19 @@ export function defineLocale (name, config) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
} else {
- if (!localeFamilies[config.parentLocale]) {
- localeFamilies[config.parentLocale] = [];
+ locale = loadLocale(config.parentLocale);
+ if (locale != null) {
+ parentConfig = locale._config;
+ } else {
+ if (!localeFamilies[config.parentLocale]) {
+ localeFamilies[config.parentLocale] = [];
+ }
+ localeFamilies[config.parentLocale].push({
+ name: name,
+ config: config
+ });
+ return null;
}
- localeFamilies[config.parentLocale].push({
- name: name,
- config: config
- });
- return null;
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
diff --git a/node_modules/moment/src/lib/moment/format.js b/node_modules/moment/src/lib/moment/format.js
index d95042f20..9544f5173 100644
--- a/node_modules/moment/src/lib/moment/format.js
+++ b/node_modules/moment/src/lib/moment/format.js
@@ -9,19 +9,24 @@ export function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
-export function toISOString() {
+export function toISOString(keepOffset) {
if (!this.isValid()) {
return null;
}
- var m = this.clone().utc();
+ var utc = keepOffset !== true;
+ var m = utc ? this.clone().utc() : this;
if (m.year() < 0 || m.year() > 9999) {
- return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ');
}
if (isFunction(Date.prototype.toISOString)) {
// native implementation is ~50x faster, use it when we can
- return this.toDate().toISOString();
+ if (utc) {
+ return this.toDate().toISOString();
+ } else {
+ return new Date(this.valueOf() + this.utcOffset() * 60 * 1000).toISOString().replace('Z', formatMoment(m, 'Z'));
+ }
}
- return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ return formatMoment(m, utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ');
}
/**
diff --git a/node_modules/moment/src/lib/parse/regex.js b/node_modules/moment/src/lib/parse/regex.js
index 5076548ed..4b86f34c7 100644
--- a/node_modules/moment/src/lib/parse/regex.js
+++ b/node_modules/moment/src/lib/parse/regex.js
@@ -20,7 +20,7 @@ export var 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
-export var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
+export var 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;
import hasOwnProp from '../utils/has-own-prop';
diff --git a/node_modules/moment/src/lib/units/day-of-month.js b/node_modules/moment/src/lib/units/day-of-month.js
index 02532534e..cbd1e40ba 100644
--- a/node_modules/moment/src/lib/units/day-of-month.js
+++ b/node_modules/moment/src/lib/units/day-of-month.js
@@ -15,7 +15,7 @@ addFormatToken('D', ['DD', 2], 'Do', 'date');
addUnitAlias('date', 'D');
-// PRIOROITY
+// PRIORITY
addUnitPriority('date', 9);
// PARSING
@@ -31,7 +31,7 @@ addRegexToken('Do', function (isStrict, locale) {
addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array) {
- array[DATE] = toInt(input.match(match1to2)[0], 10);
+ array[DATE] = toInt(input.match(match1to2)[0]);
});
// MOMENTS
diff --git a/node_modules/moment/src/lib/units/day-of-week.js b/node_modules/moment/src/lib/units/day-of-week.js
index 55027608d..438160b87 100644
--- a/node_modules/moment/src/lib/units/day-of-week.js
+++ b/node_modules/moment/src/lib/units/day-of-week.js
@@ -200,9 +200,9 @@ export function localeWeekdaysParse (weekdayName, format, strict) {
mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
- this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
- this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
- this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
+ this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
+ this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
+ this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
}
if (!this._weekdaysParse[i]) {
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
diff --git a/node_modules/moment/src/lib/units/hour.js b/node_modules/moment/src/lib/units/hour.js
index ef7586803..d717a7999 100644
--- a/node_modules/moment/src/lib/units/hour.js
+++ b/node_modules/moment/src/lib/units/hour.js
@@ -138,7 +138,7 @@ export function localeMeridiem (hours, minutes, isLower) {
// MOMENTS
// Setting the hour should keep the time, because the user explicitly
-// specified which hour he wants. So trying to maintain the same hour (in
+// specified which hour they want. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
export var getSetHour = makeGetSet('Hours', true);