summaryrefslogtreecommitdiffstats
path: root/js/vendor/momentjs/moment.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/momentjs/moment.js')
-rw-r--r--js/vendor/momentjs/moment.js237
1 files changed, 172 insertions, 65 deletions
diff --git a/js/vendor/momentjs/moment.js b/js/vendor/momentjs/moment.js
index 85e190d4a..c635ec0b3 100644
--- a/js/vendor/momentjs/moment.js
+++ b/js/vendor/momentjs/moment.js
@@ -1,5 +1,5 @@
//! moment.js
-//! version : 2.8.4
+//! version : 2.9.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
@@ -10,9 +10,9 @@
************************************/
var moment,
- VERSION = '2.8.4',
+ VERSION = '2.9.0',
// the global-scope this is NOT the global object in Node.js
- globalScope = typeof global !== 'undefined' ? global : this,
+ globalScope = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : this,
oldGlobalMoment,
round = Math.round,
hasOwnProperty = Object.prototype.hasOwnProperty,
@@ -89,7 +89,7 @@
['HH', /(T| )\d\d/]
],
- // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-15', '30']
+ // timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-', '15', '30']
parseTimezoneChunker = /([\+\-]|\d\d)/gi,
// getter and setter names
@@ -249,7 +249,7 @@
return leftZeroFill(this.milliseconds(), 3);
},
Z : function () {
- var a = -this.zone(),
+ var a = this.utcOffset(),
b = '+';
if (a < 0) {
a = -a;
@@ -258,7 +258,7 @@
return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);
},
ZZ : function () {
- var a = -this.zone(),
+ var a = this.utcOffset(),
b = '+';
if (a < 0) {
a = -a;
@@ -285,7 +285,9 @@
deprecations = {},
- lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'];
+ lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],
+
+ updateInProgress = false;
// Pick the first defined of two or three arguments. dfl comes from
// default.
@@ -354,6 +356,26 @@
};
}
+ function monthDiff(a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ return -(wholeMonthDiff + adjust);
+ }
+
while (ordinalizeTokens.length) {
i = ordinalizeTokens.pop();
formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
@@ -365,6 +387,31 @@
formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
+ function meridiemFixWrap(locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // thie is not supposed to happen
+ return hour;
+ }
+ }
+
/************************************
Constructors
************************************/
@@ -379,6 +426,13 @@
}
copyConfig(this, config);
this._d = new Date(+config._d);
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ moment.updateOffset(this);
+ updateInProgress = false;
+ }
}
// Duration Constructor
@@ -782,7 +836,8 @@
return locales[name];
}
- // Return a moment from input, that is local/utc/zone equivalent to model.
+ // Return a moment from input, that is local/utc/utcOffset equivalent to
+ // model.
function makeAs(input, model) {
var res, diff;
if (model._isUTC) {
@@ -931,6 +986,7 @@
}
},
+
_calendar : {
sameDay : '[Today at] LT',
nextDay : '[Tomorrow at] LT',
@@ -995,6 +1051,14 @@
doy : 6 // The week that contains Jan 1st is the first week of the year.
},
+ firstDayOfWeek : function () {
+ return this._week.dow;
+ },
+
+ firstDayOfYear : function () {
+ return this._week.doy;
+ },
+
_invalidDate: 'Invalid date',
invalidDate: function () {
return this._invalidDate;
@@ -1161,14 +1225,14 @@
}
}
- function timezoneMinutesFromString(string) {
+ function utcOffsetFromString(string) {
string = string || '';
var possibleTzMatches = (string.match(parseTokenTimezone) || []),
tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],
parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
minutes = +(parts[1] * 60) + toInt(parts[2]);
- return parts[0] === '+' ? -minutes : minutes;
+ return parts[0] === '+' ? minutes : -minutes;
}
// function to convert string input to date
@@ -1232,7 +1296,8 @@
// AM / PM
case 'a' : // fall through to A
case 'A' :
- config._isPm = config._locale.isPM(input);
+ config._meridiem = input;
+ // config._isPm = config._locale.isPM(input);
break;
// HOUR
case 'h' : // fall through to hh
@@ -1272,7 +1337,7 @@
case 'Z' : // fall through to ZZ
case 'ZZ' :
config._useUTC = true;
- config._tzm = timezoneMinutesFromString(input);
+ config._tzm = utcOffsetFromString(input);
break;
// WEEKDAY - human
case 'dd':
@@ -1410,10 +1475,10 @@
}
config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
- // Apply timezone offset from input. The actual zone can be changed
+ // Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
- config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
@@ -1509,14 +1574,9 @@
if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
config._pf.bigHour = undefined;
}
- // handle am pm
- if (config._isPm && config._a[HOUR] < 12) {
- config._a[HOUR] += 12;
- }
- // if is 12 am, change hours to 0
- if (config._isPm === false && config._a[HOUR] === 12) {
- config._a[HOUR] = 0;
- }
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR],
+ config._meridiem);
dateFromConfig(config);
checkOverflow(config);
}
@@ -1958,6 +2018,8 @@
s: parseIso(match[7]),
w: parseIso(match[8])
};
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
} else if (typeof duration === 'object' &&
('from' in duration || 'to' in duration)) {
diffRes = momentsDifference(moment(duration.from), moment(duration.to));
@@ -2122,6 +2184,8 @@
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
+ moment.isDate = isDate;
+
/************************************
Moment Prototype
************************************/
@@ -2134,7 +2198,7 @@
},
valueOf : function () {
- return +this._d + ((this._offset || 0) * 60000);
+ return +this._d - ((this._offset || 0) * 60000);
},
unix : function () {
@@ -2197,16 +2261,16 @@
},
utc : function (keepLocalTime) {
- return this.zone(0, keepLocalTime);
+ return this.utcOffset(0, keepLocalTime);
},
local : function (keepLocalTime) {
if (this._isUTC) {
- this.zone(0, keepLocalTime);
+ this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
- this.add(this._dateTzOffset(), 'm');
+ this.subtract(this._dateUtcOffset(), 'm');
}
}
return this;
@@ -2223,29 +2287,20 @@
diff : function (input, units, asFloat) {
var that = makeAs(input, this),
- zoneDiff = (this.zone() - that.zone()) * 6e4,
- diff, output, daysAdjust;
+ zoneDiff = (that.utcOffset() - this.utcOffset()) * 6e4,
+ anchor, diff, output, daysAdjust;
units = normalizeUnits(units);
- if (units === 'year' || units === 'month') {
- // average number of days in the months in the given dates
- diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
- // difference in months
- output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
- // adjust by taking difference in days, average number of days
- // and dst in the given months.
- daysAdjust = (this - moment(this).startOf('month')) -
- (that - moment(that).startOf('month'));
- // same as above but with zones, to negate all dst
- daysAdjust -= ((this.zone() - moment(this).startOf('month').zone()) -
- (that.zone() - moment(that).startOf('month').zone())) * 6e4;
- output += daysAdjust / diff;
- if (units === 'year') {
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
output = output / 12;
}
} else {
- diff = (this - that);
+ diff = this - that;
output = units === 'second' ? diff / 1e3 : // 1000
units === 'minute' ? diff / 6e4 : // 1000 * 60
units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
@@ -2266,7 +2321,8 @@
calendar : function (time) {
// We want to compare the start of today, vs this.
- // Getting start-of-today depends on whether we're zone'd or not.
+ // Getting start-of-today depends on whether we're locat/utc/offset
+ // or not.
var now = time || moment(),
sod = makeAs(now, this).startOf('day'),
diff = this.diff(sod, 'days', true),
@@ -2284,8 +2340,8 @@
},
isDST : function () {
- return (this.zone() < this.clone().month(0).zone() ||
- this.zone() < this.clone().month(5).zone());
+ return (this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset());
},
day : function (input) {
@@ -2375,6 +2431,10 @@
}
},
+ isBetween: function (from, to, units) {
+ return this.isAfter(from, units) && this.isBefore(to, units);
+ },
+
isSame: function (input, units) {
var inputMs;
units = normalizeUnits(units || 'millisecond');
@@ -2403,9 +2463,27 @@
}
),
+ zone : deprecate(
+ 'moment().zone is deprecated, use moment().utcOffset instead. ' +
+ 'https://github.com/moment/moment/issues/1779',
+ function (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+ }
+ ),
+
// keepLocalTime = true means only change the timezone, without
- // affecting the local hour. So 5:31:26 +0300 --[zone(2, true)]-->
- // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist int zone
+ // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+ // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
@@ -2413,38 +2491,51 @@
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
- zone : function (input, keepLocalTime) {
+ utcOffset : function (input, keepLocalTime) {
var offset = this._offset || 0,
localAdjust;
if (input != null) {
if (typeof input === 'string') {
- input = timezoneMinutesFromString(input);
+ input = utcOffsetFromString(input);
}
if (Math.abs(input) < 16) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
- localAdjust = this._dateTzOffset();
+ localAdjust = this._dateUtcOffset();
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
- this.subtract(localAdjust, 'm');
+ this.add(localAdjust, 'm');
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
addOrSubtractDurationFromMoment(this,
- moment.duration(offset - input, 'm'), 1, false);
+ moment.duration(input - offset, 'm'), 1, false);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
moment.updateOffset(this, true);
this._changeInProgress = null;
}
}
+
+ return this;
} else {
- return this._isUTC ? offset : this._dateTzOffset();
+ return this._isUTC ? offset : this._dateUtcOffset();
}
- return this;
+ },
+
+ isLocal : function () {
+ return !this._isUTC;
+ },
+
+ isUtcOffset : function () {
+ return this._isUTC;
+ },
+
+ isUtc : function () {
+ return this._isUTC && this._offset === 0;
},
zoneAbbr : function () {
@@ -2457,9 +2548,9 @@
parseZone : function () {
if (this._tzm) {
- this.zone(this._tzm);
+ this.utcOffset(this._tzm);
} else if (typeof this._i === 'string') {
- this.zone(this._i);
+ this.utcOffset(utcOffsetFromString(this._i));
}
return this;
},
@@ -2469,10 +2560,10 @@
input = 0;
}
else {
- input = moment(input).zone();
+ input = moment(input).utcOffset();
}
- return (this.zone() - input) % 60 === 0;
+ return (this.utcOffset() - input) % 60 === 0;
},
daysInMonth : function () {
@@ -2535,9 +2626,17 @@
},
set : function (units, value) {
- units = normalizeUnits(units);
- if (typeof this[units] === 'function') {
- this[units](value);
+ var unit;
+ if (typeof units === 'object') {
+ for (unit in units) {
+ this.set(unit, units[unit]);
+ }
+ }
+ else {
+ units = normalizeUnits(units);
+ if (typeof this[units] === 'function') {
+ this[units](value);
+ }
}
return this;
},
@@ -2574,11 +2673,12 @@
return this._locale;
},
- _dateTzOffset : function () {
+ _dateUtcOffset : function () {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
- return Math.round(this._d.getTimezoneOffset() / 15) * 15;
+ return -Math.round(this._d.getTimezoneOffset() / 15) * 15;
}
+
});
function rawMonthSetter(mom, value) {
@@ -2647,6 +2747,9 @@
// add aliased format methods
moment.fn.toJSON = moment.fn.toISOString;
+ // alias isUtc for dev-friendliness
+ moment.fn.isUTC = moment.fn.isUtc;
+
/************************************
Duration Prototype
************************************/
@@ -2834,6 +2937,10 @@
localeData : function () {
return this._locale;
+ },
+
+ toJSON : function () {
+ return this.toISOString();
}
});
@@ -2921,7 +3028,7 @@
if (hasModule) {
module.exports = moment;
} else if (typeof define === 'function' && define.amd) {
- define('moment', function (require, exports, module) {
+ define(function (require, exports, module) {
if (module.config && module.config() && module.config().noGlobal === true) {
// release the global variable
globalScope.moment = oldGlobalMoment;