aboutsummaryrefslogtreecommitdiffstats
path: root/bower_components/moment/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bower_components/moment/src/lib')
-rw-r--r--bower_components/moment/src/lib/create/from-anything.js23
-rw-r--r--bower_components/moment/src/lib/create/from-string.js6
-rw-r--r--bower_components/moment/src/lib/create/valid.js1
-rw-r--r--bower_components/moment/src/lib/duration/as.js6
-rw-r--r--bower_components/moment/src/lib/duration/bubble.js39
-rw-r--r--bower_components/moment/src/lib/duration/iso-string.js36
-rw-r--r--bower_components/moment/src/lib/format/format.js7
-rw-r--r--bower_components/moment/src/lib/locale/formats.js22
-rw-r--r--bower_components/moment/src/lib/locale/locales.js4
-rw-r--r--bower_components/moment/src/lib/moment/calendar.js4
-rw-r--r--bower_components/moment/src/lib/moment/constructor.js2
-rw-r--r--bower_components/moment/src/lib/moment/min-max.js2
-rw-r--r--bower_components/moment/src/lib/moment/prototype.js3
-rw-r--r--bower_components/moment/src/lib/moment/to-type.js13
-rw-r--r--bower_components/moment/src/lib/parse/regex.js9
-rw-r--r--bower_components/moment/src/lib/units/day-of-week.js28
-rw-r--r--bower_components/moment/src/lib/units/day-of-year.js18
-rw-r--r--bower_components/moment/src/lib/units/millisecond.js38
-rw-r--r--bower_components/moment/src/lib/units/offset.js31
-rw-r--r--bower_components/moment/src/lib/units/year.js6
-rw-r--r--bower_components/moment/src/lib/utils/abs-ceil.js7
-rw-r--r--bower_components/moment/src/lib/utils/deprecate.js5
-rw-r--r--bower_components/moment/src/lib/utils/to-int.js8
-rw-r--r--bower_components/moment/src/lib/utils/zero-fill.js10
24 files changed, 208 insertions, 120 deletions
diff --git a/bower_components/moment/src/lib/create/from-anything.js b/bower_components/moment/src/lib/create/from-anything.js
index 4b836c0..5a69dc5 100644
--- a/bower_components/moment/src/lib/create/from-anything.js
+++ b/bower_components/moment/src/lib/create/from-anything.js
@@ -14,9 +14,19 @@ import { configFromArray } from './from-array';
import { configFromObject } from './from-object';
function createFromConfig (config) {
+ var res = new Moment(checkOverflow(prepareConfig(config)));
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+}
+
+export function prepareConfig (config) {
var input = config._i,
- format = config._f,
- res;
+ format = config._f;
config._locale = config._locale || getLocale(config._l);
@@ -40,14 +50,7 @@ function createFromConfig (config) {
configFromInput(config);
}
- res = new Moment(checkOverflow(config));
- if (res._nextDay) {
- // Adding is smart enough around DST
- res.add(1, 'd');
- res._nextDay = undefined;
- }
-
- return res;
+ return config;
}
function configFromInput(config) {
diff --git a/bower_components/moment/src/lib/create/from-string.js b/bower_components/moment/src/lib/create/from-string.js
index 4bd6d59..4a7163b 100644
--- a/bower_components/moment/src/lib/create/from-string.js
+++ b/bower_components/moment/src/lib/create/from-string.js
@@ -36,14 +36,14 @@ export function configFromISO(config) {
getParsingFlags(config).iso = true;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(string)) {
- // match[5] should be 'T' or undefined
- config._f = isoDates[i][0] + (match[6] || ' ');
+ config._f = isoDates[i][0];
break;
}
}
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(string)) {
- config._f += isoTimes[i][0];
+ // match[6] should be 'T' or space
+ config._f += (match[6] || ' ') + isoTimes[i][0];
break;
}
}
diff --git a/bower_components/moment/src/lib/create/valid.js b/bower_components/moment/src/lib/create/valid.js
index 89204f8..ad56bfe 100644
--- a/bower_components/moment/src/lib/create/valid.js
+++ b/bower_components/moment/src/lib/create/valid.js
@@ -9,6 +9,7 @@ export function isValid(m) {
flags.overflow < 0 &&
!flags.empty &&
!flags.invalidMonth &&
+ !flags.invalidWeekday &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated;
diff --git a/bower_components/moment/src/lib/duration/as.js b/bower_components/moment/src/lib/duration/as.js
index 258c501..03ecd6d 100644
--- a/bower_components/moment/src/lib/duration/as.js
+++ b/bower_components/moment/src/lib/duration/as.js
@@ -1,4 +1,4 @@
-import { daysToYears, yearsToDays } from './bubble';
+import { daysToMonths, monthsToDays } from './bubble';
import { normalizeUnits } from '../units/aliases';
import toInt from '../utils/to-int';
@@ -11,11 +11,11 @@ export function as (units) {
if (units === 'month' || units === 'year') {
days = this._days + milliseconds / 864e5;
- months = this._months + daysToYears(days) * 12;
+ months = this._months + daysToMonths(days);
return units === 'month' ? months : months / 12;
} else {
// handle milliseconds separately because of floating point math errors (issue #1867)
- days = this._days + Math.round(yearsToDays(this._months / 12));
+ days = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case 'week' : return days / 7 + milliseconds / 6048e5;
case 'day' : return days + milliseconds / 864e5;
diff --git a/bower_components/moment/src/lib/duration/bubble.js b/bower_components/moment/src/lib/duration/bubble.js
index 3dae6b2..0c4a336 100644
--- a/bower_components/moment/src/lib/duration/bubble.js
+++ b/bower_components/moment/src/lib/duration/bubble.js
@@ -1,11 +1,22 @@
import absFloor from '../utils/abs-floor';
+import absCeil from '../utils/abs-ceil';
+import { createUTCDate } from '../create/date-from-array';
export function bubble () {
var milliseconds = this._milliseconds;
var days = this._days;
var months = this._months;
var data = this._data;
- var seconds, minutes, hours, years = 0;
+ var seconds, minutes, hours, years, monthsFromDays;
+
+ // 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))) {
+ milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
+ days = 0;
+ months = 0;
+ }
// The following code bubbles up values, see the tests for
// examples of what that means.
@@ -22,17 +33,13 @@ export function bubble () {
days += absFloor(hours / 24);
- // Accurately convert days to years, assume start from year 0.
- years = absFloor(daysToYears(days));
- days -= absFloor(yearsToDays(years));
-
- // 30 days to a month
- // TODO (iskren): Use anchor date (like 1st Jan) to compute this.
- months += absFloor(days / 30);
- days %= 30;
+ // convert days to months
+ monthsFromDays = absFloor(daysToMonths(days));
+ months += monthsFromDays;
+ days -= absCeil(monthsToDays(monthsFromDays));
// 12 months -> 1 year
- years += absFloor(months / 12);
+ years = absFloor(months / 12);
months %= 12;
data.days = days;
@@ -42,13 +49,13 @@ export function bubble () {
return this;
}
-export function daysToYears (days) {
+export function daysToMonths (days) {
// 400 years have 146097 days (taking into account leap year rules)
- return days * 400 / 146097;
+ // 400 years have 12 months === 4800
+ return days * 4800 / 146097;
}
-export function yearsToDays (years) {
- // years * 365 + absFloor(years / 4) -
- // absFloor(years / 100) + absFloor(years / 400);
- return years * 146097 / 400;
+export function monthsToDays (months) {
+ // the reverse of daysToMonths
+ return months * 146097 / 4800;
}
diff --git a/bower_components/moment/src/lib/duration/iso-string.js b/bower_components/moment/src/lib/duration/iso-string.js
index 2670a9d..f33a968 100644
--- a/bower_components/moment/src/lib/duration/iso-string.js
+++ b/bower_components/moment/src/lib/duration/iso-string.js
@@ -1,13 +1,37 @@
+import absFloor from '../utils/abs-floor';
var abs = Math.abs;
export 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
+ // * months bubble up until they become years
+ // This is because there is no context-free conversion between hours and days
+ // (think of clock changes)
+ // and also not between days and months (28-31 days per month)
+ var seconds = abs(this._milliseconds) / 1000;
+ var days = abs(this._days);
+ var months = abs(this._months);
+ var minutes, hours, years;
+
+ // 3600 seconds -> 60 minutes -> 1 hour
+ minutes = absFloor(seconds / 60);
+ hours = absFloor(minutes / 60);
+ seconds %= 60;
+ minutes %= 60;
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
- var Y = abs(this.years());
- var M = abs(this.months());
- var D = abs(this.days());
- var h = abs(this.hours());
- var m = abs(this.minutes());
- var s = abs(this.seconds() + this.milliseconds() / 1000);
+ var Y = years;
+ var M = months;
+ var D = days;
+ var h = hours;
+ var m = minutes;
+ var s = seconds;
var total = this.asSeconds();
if (!total) {
diff --git a/bower_components/moment/src/lib/format/format.js b/bower_components/moment/src/lib/format/format.js
index 565da01..5378170 100644
--- a/bower_components/moment/src/lib/format/format.js
+++ b/bower_components/moment/src/lib/format/format.js
@@ -1,6 +1,6 @@
import zeroFill from '../utils/zero-fill';
-export var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g;
+export var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|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 localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
@@ -68,10 +68,7 @@ export function formatMoment(m, format) {
}
format = expandFormat(format, m.localeData());
-
- if (!formatFunctions[format]) {
- formatFunctions[format] = makeFormatFunction(format);
- }
+ formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](m);
}
diff --git a/bower_components/moment/src/lib/locale/formats.js b/bower_components/moment/src/lib/locale/formats.js
index 22b75ad..6d83b03 100644
--- a/bower_components/moment/src/lib/locale/formats.js
+++ b/bower_components/moment/src/lib/locale/formats.js
@@ -3,17 +3,21 @@ export var defaultLongDateFormat = {
LT : 'h:mm A',
L : 'MM/DD/YYYY',
LL : 'MMMM D, YYYY',
- LLL : 'MMMM D, YYYY LT',
- LLLL : 'dddd, MMMM D, YYYY LT'
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
};
export function longDateFormat (key) {
- var output = this._longDateFormat[key];
- if (!output && this._longDateFormat[key.toUpperCase()]) {
- output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
- return val.slice(1);
- });
- this._longDateFormat[key] = output;
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()];
+
+ if (format || !formatUpper) {
+ return format;
}
- return output;
+
+ this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+
+ return this._longDateFormat[key];
}
diff --git a/bower_components/moment/src/lib/locale/locales.js b/bower_components/moment/src/lib/locale/locales.js
index 0e58ded..a32e5ac 100644
--- a/bower_components/moment/src/lib/locale/locales.js
+++ b/bower_components/moment/src/lib/locale/locales.js
@@ -78,9 +78,7 @@ export function getSetGlobalLocale (key, values) {
export function defineLocale (name, values) {
if (values !== null) {
values.abbr = name;
- if (!locales[name]) {
- locales[name] = new Locale();
- }
+ locales[name] = locales[name] || new Locale();
locales[name].set(values);
// backwards compat for now: also set the locale
diff --git a/bower_components/moment/src/lib/moment/calendar.js b/bower_components/moment/src/lib/moment/calendar.js
index 66d70ad..c9df803 100644
--- a/bower_components/moment/src/lib/moment/calendar.js
+++ b/bower_components/moment/src/lib/moment/calendar.js
@@ -1,7 +1,7 @@
import { createLocal } from '../create/local';
import { cloneWithOffset } from '../units/offset';
-export function calendar (time) {
+export function calendar (time, formats) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || createLocal(),
@@ -13,5 +13,5 @@ export function calendar (time) {
diff < 1 ? 'sameDay' :
diff < 2 ? 'nextDay' :
diff < 7 ? 'nextWeek' : 'sameElse';
- return this.format(this.localeData().calendar(format, this, createLocal(now)));
+ return this.format(formats && formats[format] || this.localeData().calendar(format, this, createLocal(now)));
}
diff --git a/bower_components/moment/src/lib/moment/constructor.js b/bower_components/moment/src/lib/moment/constructor.js
index f735593..f5f3da0 100644
--- a/bower_components/moment/src/lib/moment/constructor.js
+++ b/bower_components/moment/src/lib/moment/constructor.js
@@ -58,7 +58,7 @@ var updateInProgress = false;
// Moment prototype object
export function Moment(config) {
copyConfig(this, config);
- this._d = new Date(+config._d);
+ this._d = new Date(config._d != null ? config._d.getTime() : NaN);
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
diff --git a/bower_components/moment/src/lib/moment/min-max.js b/bower_components/moment/src/lib/moment/min-max.js
index c4a88d2..912cbfe 100644
--- a/bower_components/moment/src/lib/moment/min-max.js
+++ b/bower_components/moment/src/lib/moment/min-max.js
@@ -33,7 +33,7 @@ function pickBy(fn, moments) {
}
res = moments[0];
for (i = 1; i < moments.length; ++i) {
- if (moments[i][fn](res)) {
+ if (!moments[i].isValid() || moments[i][fn](res)) {
res = moments[i];
}
}
diff --git a/bower_components/moment/src/lib/moment/prototype.js b/bower_components/moment/src/lib/moment/prototype.js
index 5601bc0..d17f743 100644
--- a/bower_components/moment/src/lib/moment/prototype.js
+++ b/bower_components/moment/src/lib/moment/prototype.js
@@ -14,7 +14,7 @@ import { getSet } from './get-set';
import { locale, localeData, lang } from './locale';
import { prototypeMin, prototypeMax } from './min-max';
import { startOf, endOf } from './start-end-of';
-import { valueOf, toDate, toArray, unix } from './to-type';
+import { valueOf, toDate, toArray, toObject, unix } from './to-type';
import { isValid, parsingFlags, invalidAt } from './valid';
proto.add = add;
@@ -44,6 +44,7 @@ proto.set = getSet;
proto.startOf = startOf;
proto.subtract = subtract;
proto.toArray = toArray;
+proto.toObject = toObject;
proto.toDate = toDate;
proto.toISOString = toISOString;
proto.toJSON = toISOString;
diff --git a/bower_components/moment/src/lib/moment/to-type.js b/bower_components/moment/src/lib/moment/to-type.js
index edc1338..3008d95 100644
--- a/bower_components/moment/src/lib/moment/to-type.js
+++ b/bower_components/moment/src/lib/moment/to-type.js
@@ -14,3 +14,16 @@ export function toArray () {
var m = this;
return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
}
+
+export function toObject () {
+ var m = this;
+ return {
+ years: m.year(),
+ months: m.month(),
+ date: m.date(),
+ hours: m.hours(),
+ minutes: m.minutes(),
+ seconds: m.seconds(),
+ milliseconds: m.milliseconds()
+ };
+}
diff --git a/bower_components/moment/src/lib/parse/regex.js b/bower_components/moment/src/lib/parse/regex.js
index 23091a0..9e7d678 100644
--- a/bower_components/moment/src/lib/parse/regex.js
+++ b/bower_components/moment/src/lib/parse/regex.js
@@ -22,8 +22,15 @@ import hasOwnProp from '../utils/has-own-prop';
var regexes = {};
+function isFunction (sth) {
+ // https://github.com/moment/moment/issues/2325
+ return typeof sth === 'function' &&
+ Object.prototype.toString.call(sth) === '[object Function]';
+}
+
+
export function addRegexToken (token, regex, strictRegex) {
- regexes[token] = typeof regex === 'function' ? regex : function (isStrict) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
diff --git a/bower_components/moment/src/lib/units/day-of-week.js b/bower_components/moment/src/lib/units/day-of-week.js
index 7af2408..a82f126 100644
--- a/bower_components/moment/src/lib/units/day-of-week.js
+++ b/bower_components/moment/src/lib/units/day-of-week.js
@@ -57,18 +57,20 @@ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
// HELPERS
function parseWeekday(input, locale) {
- if (typeof input === 'string') {
- if (!isNaN(input)) {
- input = parseInt(input, 10);
- }
- else {
- input = locale.weekdaysParse(input);
- if (typeof input !== 'number') {
- return null;
- }
- }
+ if (typeof input !== 'string') {
+ return input;
+ }
+
+ if (!isNaN(input)) {
+ return parseInt(input, 10);
}
- return input;
+
+ input = locale.weekdaysParse(input);
+ if (typeof input === 'number') {
+ return input;
+ }
+
+ return null;
}
// LOCALES
@@ -91,9 +93,7 @@ export function localeWeekdaysMin (m) {
export function localeWeekdaysParse (weekdayName) {
var i, mom, regex;
- if (!this._weekdaysParse) {
- this._weekdaysParse = [];
- }
+ this._weekdaysParse = this._weekdaysParse || [];
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
diff --git a/bower_components/moment/src/lib/units/day-of-year.js b/bower_components/moment/src/lib/units/day-of-year.js
index 7c4d286..0c34fa3 100644
--- a/bower_components/moment/src/lib/units/day-of-year.js
+++ b/bower_components/moment/src/lib/units/day-of-year.js
@@ -26,18 +26,18 @@ addParseToken(['DDD', 'DDDD'], function (input, array, config) {
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
export function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
- var d = createUTCDate(year, 0, 1).getUTCDay();
- var daysToAdd;
- var dayOfYear;
+ var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
+ if (d < firstDayOfWeek) {
+ d += 7;
+ }
- d = d === 0 ? 7 : d;
- weekday = weekday != null ? weekday : firstDayOfWeek;
- daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
- dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
+ weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
+
+ dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
return {
- year : dayOfYear > 0 ? year : year - 1,
- dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
+ year: dayOfYear > 0 ? year : year - 1,
+ dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
};
}
diff --git a/bower_components/moment/src/lib/units/millisecond.js b/bower_components/moment/src/lib/units/millisecond.js
index 2fb73af..134d88e 100644
--- a/bower_components/moment/src/lib/units/millisecond.js
+++ b/bower_components/moment/src/lib/units/millisecond.js
@@ -16,12 +16,26 @@ addFormatToken(0, ['SS', 2], 0, function () {
return ~~(this.millisecond() / 10);
});
-function milliseconds (token) {
- addFormatToken(0, [token, 3], 0, 'millisecond');
-}
+addFormatToken(0, ['SSS', 3], 0, 'millisecond');
+addFormatToken(0, ['SSSS', 4], 0, function () {
+ return this.millisecond() * 10;
+});
+addFormatToken(0, ['SSSSS', 5], 0, function () {
+ return this.millisecond() * 100;
+});
+addFormatToken(0, ['SSSSSS', 6], 0, function () {
+ return this.millisecond() * 1000;
+});
+addFormatToken(0, ['SSSSSSS', 7], 0, function () {
+ return this.millisecond() * 10000;
+});
+addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
+ return this.millisecond() * 100000;
+});
+addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
+ return this.millisecond() * 1000000;
+});
-milliseconds('SSS');
-milliseconds('SSSS');
// ALIASES
@@ -32,11 +46,19 @@ addUnitAlias('millisecond', 'ms');
addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);
-addRegexToken('SSSS', matchUnsigned);
-addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) {
+
+var token;
+for (token = 'SSSS'; token.length <= 9; token += 'S') {
+ addRegexToken(token, matchUnsigned);
+}
+
+function parseMs(input, array) {
array[MILLISECOND] = toInt(('0.' + input) * 1000);
-});
+}
+for (token = 'S'; token.length <= 9; token += 'S') {
+ addParseToken(token, parseMs);
+}
// MOMENTS
export var getSetMillisecond = makeGetSet('Milliseconds', false);
diff --git a/bower_components/moment/src/lib/units/offset.js b/bower_components/moment/src/lib/units/offset.js
index 75aeb02..33288c0 100644
--- a/bower_components/moment/src/lib/units/offset.js
+++ b/bower_components/moment/src/lib/units/offset.js
@@ -1,11 +1,12 @@
import zeroFill from '../utils/zero-fill';
import { createDuration } from '../duration/create';
import { addSubtract } from '../moment/add-subtract';
-import { isMoment } from '../moment/constructor';
+import { isMoment, copyConfig } from '../moment/constructor';
import { addFormatToken } from '../format/format';
import { addRegexToken, matchOffset } from '../parse/regex';
import { addParseToken } from '../parse/token';
import { createLocal } from '../create/local';
+import { prepareConfig } from '../create/from-anything';
import { createUTC } from '../create/utc';
import isDate from '../utils/is-date';
import toInt from '../utils/to-int';
@@ -67,7 +68,6 @@ export function cloneWithOffset(input, model) {
} else {
return createLocal(input).local();
}
- return model._isUTC ? createLocal(input).zone(model._offset || 0) : createLocal(input).local();
}
function getDateOffset (m) {
@@ -167,12 +167,7 @@ export function setOffsetToParsedOffset () {
}
export function hasAlignedHourOffset (input) {
- if (!input) {
- input = 0;
- }
- else {
- input = createLocal(input).utcOffset();
- }
+ input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}
@@ -185,12 +180,24 @@ export function isDaylightSavingTime () {
}
export function isDaylightSavingTimeShifted () {
- if (this._a) {
- var other = this._isUTC ? createUTC(this._a) : createLocal(this._a);
- return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
+ if (typeof this._isDSTShifted !== 'undefined') {
+ return this._isDSTShifted;
+ }
+
+ var c = {};
+
+ copyConfig(c, this);
+ c = prepareConfig(c);
+
+ if (c._a) {
+ var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
+ this._isDSTShifted = this.isValid() &&
+ compareArrays(c._a, other.toArray()) > 0;
+ } else {
+ this._isDSTShifted = false;
}
- return false;
+ return this._isDSTShifted;
}
export function isLocal () {
diff --git a/bower_components/moment/src/lib/units/year.js b/bower_components/moment/src/lib/units/year.js
index 4d8a03b..cc32b55 100644
--- a/bower_components/moment/src/lib/units/year.js
+++ b/bower_components/moment/src/lib/units/year.js
@@ -29,7 +29,10 @@ addRegexToken('YYYY', match1to4, match4);
addRegexToken('YYYYY', match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);
-addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
+addParseToken(['YYYYY', 'YYYYYY'], YEAR);
+addParseToken('YYYY', function (input, array) {
+ array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
+});
addParseToken('YY', function (input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
@@ -57,4 +60,3 @@ export var getSetYear = makeGetSet('FullYear', false);
export function getIsLeapYear () {
return isLeapYear(this.year());
}
-
diff --git a/bower_components/moment/src/lib/utils/abs-ceil.js b/bower_components/moment/src/lib/utils/abs-ceil.js
new file mode 100644
index 0000000..7cf9329
--- /dev/null
+++ b/bower_components/moment/src/lib/utils/abs-ceil.js
@@ -0,0 +1,7 @@
+export default function absCeil (number) {
+ if (number < 0) {
+ return Math.floor(number);
+ } else {
+ return Math.ceil(number);
+ }
+}
diff --git a/bower_components/moment/src/lib/utils/deprecate.js b/bower_components/moment/src/lib/utils/deprecate.js
index a076ad7..df4286b 100644
--- a/bower_components/moment/src/lib/utils/deprecate.js
+++ b/bower_components/moment/src/lib/utils/deprecate.js
@@ -8,12 +8,11 @@ function warn(msg) {
}
export function deprecate(msg, fn) {
- var firstTime = true,
- msgWithStack = msg + '\n' + (new Error()).stack;
+ var firstTime = true;
return extend(function () {
if (firstTime) {
- warn(msgWithStack);
+ warn(msg + '\n' + (new Error()).stack);
firstTime = false;
}
return fn.apply(this, arguments);
diff --git a/bower_components/moment/src/lib/utils/to-int.js b/bower_components/moment/src/lib/utils/to-int.js
index 945e019..fb48941 100644
--- a/bower_components/moment/src/lib/utils/to-int.js
+++ b/bower_components/moment/src/lib/utils/to-int.js
@@ -1,13 +1,11 @@
+import absFloor from './abs-floor';
+
export default function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion,
value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
- if (coercedNumber >= 0) {
- value = Math.floor(coercedNumber);
- } else {
- value = Math.ceil(coercedNumber);
- }
+ value = absFloor(coercedNumber);
}
return value;
diff --git a/bower_components/moment/src/lib/utils/zero-fill.js b/bower_components/moment/src/lib/utils/zero-fill.js
index af45dd9..7009ec9 100644
--- a/bower_components/moment/src/lib/utils/zero-fill.js
+++ b/bower_components/moment/src/lib/utils/zero-fill.js
@@ -1,9 +1,7 @@
export default function zeroFill(number, targetLength, forceSign) {
- var output = '' + Math.abs(number),
+ var absNumber = '' + Math.abs(number),
+ zerosToFill = targetLength - absNumber.length,
sign = number >= 0;
-
- while (output.length < targetLength) {
- output = '0' + output;
- }
- return (sign ? (forceSign ? '+' : '') : '-') + output;
+ return (sign ? (forceSign ? '+' : '') : '-') +
+ Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}