Path: blob/master/web-gui/buildyourownbotnet/assets/js/daterangepicker/moment.js
1293 views
//! moment.js1//! version : 2.9.02//! authors : Tim Wood, Iskren Chernev, Moment.js contributors3//! license : MIT4//! momentjs.com56(function (undefined) {7/************************************8Constants9************************************/1011var moment,12VERSION = '2.9.0',13// the global-scope this is NOT the global object in Node.js14globalScope = (typeof global !== 'undefined' && (typeof window === 'undefined' || window === global.window)) ? global : this,15oldGlobalMoment,16round = Math.round,17hasOwnProperty = Object.prototype.hasOwnProperty,18i,1920YEAR = 0,21MONTH = 1,22DATE = 2,23HOUR = 3,24MINUTE = 4,25SECOND = 5,26MILLISECOND = 6,2728// internal storage for locale config files29locales = {},3031// extra moment internal properties (plugins register props here)32momentProperties = [],3334// check for nodeJS35hasModule = (typeof module !== 'undefined' && module && module.exports),3637// ASP.NET json date format regex38aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,39aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,4041// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html42// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere43isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,4445// format tokens46formattingTokens = /(\[[^\[]*\])|(\\)?(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,47localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,4849// parsing token regexes50parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 9951parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 99952parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 999953parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,99954parseTokenDigits = /\d+/, // nonzero number of digits55parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.56parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z57parseTokenT = /T/i, // T (ISO separator)58parseTokenOffsetMs = /[\+\-]?\d+/, // 123456789012359parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.1236061//strict parsing regexes62parseTokenOneDigit = /\d/, // 0 - 963parseTokenTwoDigits = /\d\d/, // 00 - 9964parseTokenThreeDigits = /\d{3}/, // 000 - 99965parseTokenFourDigits = /\d{4}/, // 0000 - 999966parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,99967parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf6869// iso 8601 regex70// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)71isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,7273isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',7475isoDates = [76['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],77['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],78['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],79['GGGG-[W]WW', /\d{4}-W\d{2}/],80['YYYY-DDD', /\d{4}-\d{3}/]81],8283// iso time formats and regexes84isoTimes = [85['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],86['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],87['HH:mm', /(T| )\d\d:\d\d/],88['HH', /(T| )\d\d/]89],9091// timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-', '15', '30']92parseTimezoneChunker = /([\+\-]|\d\d)/gi,9394// getter and setter names95proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'),96unitMillisecondFactors = {97'Milliseconds' : 1,98'Seconds' : 1e3,99'Minutes' : 6e4,100'Hours' : 36e5,101'Days' : 864e5,102'Months' : 2592e6,103'Years' : 31536e6104},105106unitAliases = {107ms : 'millisecond',108s : 'second',109m : 'minute',110h : 'hour',111d : 'day',112D : 'date',113w : 'week',114W : 'isoWeek',115M : 'month',116Q : 'quarter',117y : 'year',118DDD : 'dayOfYear',119e : 'weekday',120E : 'isoWeekday',121gg: 'weekYear',122GG: 'isoWeekYear'123},124125camelFunctions = {126dayofyear : 'dayOfYear',127isoweekday : 'isoWeekday',128isoweek : 'isoWeek',129weekyear : 'weekYear',130isoweekyear : 'isoWeekYear'131},132133// format function strings134formatFunctions = {},135136// default relative time thresholds137relativeTimeThresholds = {138s: 45, // seconds to minute139m: 45, // minutes to hour140h: 22, // hours to day141d: 26, // days to month142M: 11 // months to year143},144145// tokens to ordinalize and pad146ordinalizeTokens = 'DDD w W M D d'.split(' '),147paddedTokens = 'M D H h m s w W'.split(' '),148149formatTokenFunctions = {150M : function () {151return this.month() + 1;152},153MMM : function (format) {154return this.localeData().monthsShort(this, format);155},156MMMM : function (format) {157return this.localeData().months(this, format);158},159D : function () {160return this.date();161},162DDD : function () {163return this.dayOfYear();164},165d : function () {166return this.day();167},168dd : function (format) {169return this.localeData().weekdaysMin(this, format);170},171ddd : function (format) {172return this.localeData().weekdaysShort(this, format);173},174dddd : function (format) {175return this.localeData().weekdays(this, format);176},177w : function () {178return this.week();179},180W : function () {181return this.isoWeek();182},183YY : function () {184return leftZeroFill(this.year() % 100, 2);185},186YYYY : function () {187return leftZeroFill(this.year(), 4);188},189YYYYY : function () {190return leftZeroFill(this.year(), 5);191},192YYYYYY : function () {193var y = this.year(), sign = y >= 0 ? '+' : '-';194return sign + leftZeroFill(Math.abs(y), 6);195},196gg : function () {197return leftZeroFill(this.weekYear() % 100, 2);198},199gggg : function () {200return leftZeroFill(this.weekYear(), 4);201},202ggggg : function () {203return leftZeroFill(this.weekYear(), 5);204},205GG : function () {206return leftZeroFill(this.isoWeekYear() % 100, 2);207},208GGGG : function () {209return leftZeroFill(this.isoWeekYear(), 4);210},211GGGGG : function () {212return leftZeroFill(this.isoWeekYear(), 5);213},214e : function () {215return this.weekday();216},217E : function () {218return this.isoWeekday();219},220a : function () {221return this.localeData().meridiem(this.hours(), this.minutes(), true);222},223A : function () {224return this.localeData().meridiem(this.hours(), this.minutes(), false);225},226H : function () {227return this.hours();228},229h : function () {230return this.hours() % 12 || 12;231},232m : function () {233return this.minutes();234},235s : function () {236return this.seconds();237},238S : function () {239return toInt(this.milliseconds() / 100);240},241SS : function () {242return leftZeroFill(toInt(this.milliseconds() / 10), 2);243},244SSS : function () {245return leftZeroFill(this.milliseconds(), 3);246},247SSSS : function () {248return leftZeroFill(this.milliseconds(), 3);249},250Z : function () {251var a = this.utcOffset(),252b = '+';253if (a < 0) {254a = -a;255b = '-';256}257return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2);258},259ZZ : function () {260var a = this.utcOffset(),261b = '+';262if (a < 0) {263a = -a;264b = '-';265}266return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2);267},268z : function () {269return this.zoneAbbr();270},271zz : function () {272return this.zoneName();273},274x : function () {275return this.valueOf();276},277X : function () {278return this.unix();279},280Q : function () {281return this.quarter();282}283},284285deprecations = {},286287lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin'],288289updateInProgress = false;290291// Pick the first defined of two or three arguments. dfl comes from292// default.293function dfl(a, b, c) {294switch (arguments.length) {295case 2: return a != null ? a : b;296case 3: return a != null ? a : b != null ? b : c;297default: throw new Error('Implement me');298}299}300301function hasOwnProp(a, b) {302return hasOwnProperty.call(a, b);303}304305function defaultParsingFlags() {306// We need to deep clone this object, and es5 standard is not very307// helpful.308return {309empty : false,310unusedTokens : [],311unusedInput : [],312overflow : -2,313charsLeftOver : 0,314nullInput : false,315invalidMonth : null,316invalidFormat : false,317userInvalidated : false,318iso: false319};320}321322function printMsg(msg) {323if (moment.suppressDeprecationWarnings === false &&324typeof console !== 'undefined' && console.warn) {325console.warn('Deprecation warning: ' + msg);326}327}328329function deprecate(msg, fn) {330var firstTime = true;331return extend(function () {332if (firstTime) {333printMsg(msg);334firstTime = false;335}336return fn.apply(this, arguments);337}, fn);338}339340function deprecateSimple(name, msg) {341if (!deprecations[name]) {342printMsg(msg);343deprecations[name] = true;344}345}346347function padToken(func, count) {348return function (a) {349return leftZeroFill(func.call(this, a), count);350};351}352function ordinalizeToken(func, period) {353return function (a) {354return this.localeData().ordinal(func.call(this, a), period);355};356}357358function monthDiff(a, b) {359// difference in months360var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),361// b is in (anchor - 1 month, anchor + 1 month)362anchor = a.clone().add(wholeMonthDiff, 'months'),363anchor2, adjust;364365if (b - anchor < 0) {366anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');367// linear across the month368adjust = (b - anchor) / (anchor - anchor2);369} else {370anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');371// linear across the month372adjust = (b - anchor) / (anchor2 - anchor);373}374375return -(wholeMonthDiff + adjust);376}377378while (ordinalizeTokens.length) {379i = ordinalizeTokens.pop();380formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);381}382while (paddedTokens.length) {383i = paddedTokens.pop();384formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);385}386formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);387388389function meridiemFixWrap(locale, hour, meridiem) {390var isPm;391392if (meridiem == null) {393// nothing to do394return hour;395}396if (locale.meridiemHour != null) {397return locale.meridiemHour(hour, meridiem);398} else if (locale.isPM != null) {399// Fallback400isPm = locale.isPM(meridiem);401if (isPm && hour < 12) {402hour += 12;403}404if (!isPm && hour === 12) {405hour = 0;406}407return hour;408} else {409// thie is not supposed to happen410return hour;411}412}413414/************************************415Constructors416************************************/417418function Locale() {419}420421// Moment prototype object422function Moment(config, skipOverflow) {423if (skipOverflow !== false) {424checkOverflow(config);425}426copyConfig(this, config);427this._d = new Date(+config._d);428// Prevent infinite loop in case updateOffset creates new moment429// objects.430if (updateInProgress === false) {431updateInProgress = true;432moment.updateOffset(this);433updateInProgress = false;434}435}436437// Duration Constructor438function Duration(duration) {439var normalizedInput = normalizeObjectUnits(duration),440years = normalizedInput.year || 0,441quarters = normalizedInput.quarter || 0,442months = normalizedInput.month || 0,443weeks = normalizedInput.week || 0,444days = normalizedInput.day || 0,445hours = normalizedInput.hour || 0,446minutes = normalizedInput.minute || 0,447seconds = normalizedInput.second || 0,448milliseconds = normalizedInput.millisecond || 0;449450// representation for dateAddRemove451this._milliseconds = +milliseconds +452seconds * 1e3 + // 1000453minutes * 6e4 + // 1000 * 60454hours * 36e5; // 1000 * 60 * 60455// Because of dateAddRemove treats 24 hours as different from a456// day when working around DST, we need to store them separately457this._days = +days +458weeks * 7;459// It is impossible translate months into days without knowing460// which months you are are talking about, so we have to store461// it separately.462this._months = +months +463quarters * 3 +464years * 12;465466this._data = {};467468this._locale = moment.localeData();469470this._bubble();471}472473/************************************474Helpers475************************************/476477478function extend(a, b) {479for (var i in b) {480if (hasOwnProp(b, i)) {481a[i] = b[i];482}483}484485if (hasOwnProp(b, 'toString')) {486a.toString = b.toString;487}488489if (hasOwnProp(b, 'valueOf')) {490a.valueOf = b.valueOf;491}492493return a;494}495496function copyConfig(to, from) {497var i, prop, val;498499if (typeof from._isAMomentObject !== 'undefined') {500to._isAMomentObject = from._isAMomentObject;501}502if (typeof from._i !== 'undefined') {503to._i = from._i;504}505if (typeof from._f !== 'undefined') {506to._f = from._f;507}508if (typeof from._l !== 'undefined') {509to._l = from._l;510}511if (typeof from._strict !== 'undefined') {512to._strict = from._strict;513}514if (typeof from._tzm !== 'undefined') {515to._tzm = from._tzm;516}517if (typeof from._isUTC !== 'undefined') {518to._isUTC = from._isUTC;519}520if (typeof from._offset !== 'undefined') {521to._offset = from._offset;522}523if (typeof from._pf !== 'undefined') {524to._pf = from._pf;525}526if (typeof from._locale !== 'undefined') {527to._locale = from._locale;528}529530if (momentProperties.length > 0) {531for (i in momentProperties) {532prop = momentProperties[i];533val = from[prop];534if (typeof val !== 'undefined') {535to[prop] = val;536}537}538}539540return to;541}542543function absRound(number) {544if (number < 0) {545return Math.ceil(number);546} else {547return Math.floor(number);548}549}550551// left zero fill a number552// see http://jsperf.com/left-zero-filling for performance comparison553function leftZeroFill(number, targetLength, forceSign) {554var output = '' + Math.abs(number),555sign = number >= 0;556557while (output.length < targetLength) {558output = '0' + output;559}560return (sign ? (forceSign ? '+' : '') : '-') + output;561}562563function positiveMomentsDifference(base, other) {564var res = {milliseconds: 0, months: 0};565566res.months = other.month() - base.month() +567(other.year() - base.year()) * 12;568if (base.clone().add(res.months, 'M').isAfter(other)) {569--res.months;570}571572res.milliseconds = +other - +(base.clone().add(res.months, 'M'));573574return res;575}576577function momentsDifference(base, other) {578var res;579other = makeAs(other, base);580if (base.isBefore(other)) {581res = positiveMomentsDifference(base, other);582} else {583res = positiveMomentsDifference(other, base);584res.milliseconds = -res.milliseconds;585res.months = -res.months;586}587588return res;589}590591// TODO: remove 'name' arg after deprecation is removed592function createAdder(direction, name) {593return function (val, period) {594var dur, tmp;595//invert the arguments, but complain about it596if (period !== null && !isNaN(+period)) {597deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');598tmp = val; val = period; period = tmp;599}600601val = typeof val === 'string' ? +val : val;602dur = moment.duration(val, period);603addOrSubtractDurationFromMoment(this, dur, direction);604return this;605};606}607608function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {609var milliseconds = duration._milliseconds,610days = duration._days,611months = duration._months;612updateOffset = updateOffset == null ? true : updateOffset;613614if (milliseconds) {615mom._d.setTime(+mom._d + milliseconds * isAdding);616}617if (days) {618rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);619}620if (months) {621rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);622}623if (updateOffset) {624moment.updateOffset(mom, days || months);625}626}627628// check if is an array629function isArray(input) {630return Object.prototype.toString.call(input) === '[object Array]';631}632633function isDate(input) {634return Object.prototype.toString.call(input) === '[object Date]' ||635input instanceof Date;636}637638// compare two arrays, return the number of differences639function compareArrays(array1, array2, dontConvert) {640var len = Math.min(array1.length, array2.length),641lengthDiff = Math.abs(array1.length - array2.length),642diffs = 0,643i;644for (i = 0; i < len; i++) {645if ((dontConvert && array1[i] !== array2[i]) ||646(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {647diffs++;648}649}650return diffs + lengthDiff;651}652653function normalizeUnits(units) {654if (units) {655var lowered = units.toLowerCase().replace(/(.)s$/, '$1');656units = unitAliases[units] || camelFunctions[lowered] || lowered;657}658return units;659}660661function normalizeObjectUnits(inputObject) {662var normalizedInput = {},663normalizedProp,664prop;665666for (prop in inputObject) {667if (hasOwnProp(inputObject, prop)) {668normalizedProp = normalizeUnits(prop);669if (normalizedProp) {670normalizedInput[normalizedProp] = inputObject[prop];671}672}673}674675return normalizedInput;676}677678function makeList(field) {679var count, setter;680681if (field.indexOf('week') === 0) {682count = 7;683setter = 'day';684}685else if (field.indexOf('month') === 0) {686count = 12;687setter = 'month';688}689else {690return;691}692693moment[field] = function (format, index) {694var i, getter,695method = moment._locale[field],696results = [];697698if (typeof format === 'number') {699index = format;700format = undefined;701}702703getter = function (i) {704var m = moment().utc().set(setter, i);705return method.call(moment._locale, m, format || '');706};707708if (index != null) {709return getter(index);710}711else {712for (i = 0; i < count; i++) {713results.push(getter(i));714}715return results;716}717};718}719720function toInt(argumentForCoercion) {721var coercedNumber = +argumentForCoercion,722value = 0;723724if (coercedNumber !== 0 && isFinite(coercedNumber)) {725if (coercedNumber >= 0) {726value = Math.floor(coercedNumber);727} else {728value = Math.ceil(coercedNumber);729}730}731732return value;733}734735function daysInMonth(year, month) {736return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();737}738739function weeksInYear(year, dow, doy) {740return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;741}742743function daysInYear(year) {744return isLeapYear(year) ? 366 : 365;745}746747function isLeapYear(year) {748return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;749}750751function checkOverflow(m) {752var overflow;753if (m._a && m._pf.overflow === -2) {754overflow =755m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :756m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :757m._a[HOUR] < 0 || m._a[HOUR] > 24 ||758(m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 ||759m._a[SECOND] !== 0 ||760m._a[MILLISECOND] !== 0)) ? HOUR :761m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE :762m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND :763m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND :764-1;765766if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {767overflow = DATE;768}769770m._pf.overflow = overflow;771}772}773774function isValid(m) {775if (m._isValid == null) {776m._isValid = !isNaN(m._d.getTime()) &&777m._pf.overflow < 0 &&778!m._pf.empty &&779!m._pf.invalidMonth &&780!m._pf.nullInput &&781!m._pf.invalidFormat &&782!m._pf.userInvalidated;783784if (m._strict) {785m._isValid = m._isValid &&786m._pf.charsLeftOver === 0 &&787m._pf.unusedTokens.length === 0 &&788m._pf.bigHour === undefined;789}790}791return m._isValid;792}793794function normalizeLocale(key) {795return key ? key.toLowerCase().replace('_', '-') : key;796}797798// pick the locale from the array799// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each800// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root801function chooseLocale(names) {802var i = 0, j, next, locale, split;803804while (i < names.length) {805split = normalizeLocale(names[i]).split('-');806j = split.length;807next = normalizeLocale(names[i + 1]);808next = next ? next.split('-') : null;809while (j > 0) {810locale = loadLocale(split.slice(0, j).join('-'));811if (locale) {812return locale;813}814if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {815//the next array item is better than a shallower substring of this one816break;817}818j--;819}820i++;821}822return null;823}824825function loadLocale(name) {826var oldLocale = null;827if (!locales[name] && hasModule) {828try {829oldLocale = moment.locale();830require('./locale/' + name);831// because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales832moment.locale(oldLocale);833} catch (e) { }834}835return locales[name];836}837838// Return a moment from input, that is local/utc/utcOffset equivalent to839// model.840function makeAs(input, model) {841var res, diff;842if (model._isUTC) {843res = model.clone();844diff = (moment.isMoment(input) || isDate(input) ?845+input : +moment(input)) - (+res);846// Use low-level api, because this fn is low-level api.847res._d.setTime(+res._d + diff);848moment.updateOffset(res, false);849return res;850} else {851return moment(input).local();852}853}854855/************************************856Locale857************************************/858859860extend(Locale.prototype, {861862set : function (config) {863var prop, i;864for (i in config) {865prop = config[i];866if (typeof prop === 'function') {867this[i] = prop;868} else {869this['_' + i] = prop;870}871}872// Lenient ordinal parsing accepts just a number in addition to873// number + (possibly) stuff coming from _ordinalParseLenient.874this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source);875},876877_months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),878months : function (m) {879return this._months[m.month()];880},881882_monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),883monthsShort : function (m) {884return this._monthsShort[m.month()];885},886887monthsParse : function (monthName, format, strict) {888var i, mom, regex;889890if (!this._monthsParse) {891this._monthsParse = [];892this._longMonthsParse = [];893this._shortMonthsParse = [];894}895896for (i = 0; i < 12; i++) {897// make the regex if we don't have it already898mom = moment.utc([2000, i]);899if (strict && !this._longMonthsParse[i]) {900this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');901this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');902}903if (!strict && !this._monthsParse[i]) {904regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');905this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');906}907// test the regex908if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {909return i;910} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {911return i;912} else if (!strict && this._monthsParse[i].test(monthName)) {913return i;914}915}916},917918_weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),919weekdays : function (m) {920return this._weekdays[m.day()];921},922923_weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),924weekdaysShort : function (m) {925return this._weekdaysShort[m.day()];926},927928_weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),929weekdaysMin : function (m) {930return this._weekdaysMin[m.day()];931},932933weekdaysParse : function (weekdayName) {934var i, mom, regex;935936if (!this._weekdaysParse) {937this._weekdaysParse = [];938}939940for (i = 0; i < 7; i++) {941// make the regex if we don't have it already942if (!this._weekdaysParse[i]) {943mom = moment([2000, 1]).day(i);944regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');945this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');946}947// test the regex948if (this._weekdaysParse[i].test(weekdayName)) {949return i;950}951}952},953954_longDateFormat : {955LTS : 'h:mm:ss A',956LT : 'h:mm A',957L : 'MM/DD/YYYY',958LL : 'MMMM D, YYYY',959LLL : 'MMMM D, YYYY LT',960LLLL : 'dddd, MMMM D, YYYY LT'961},962longDateFormat : function (key) {963var output = this._longDateFormat[key];964if (!output && this._longDateFormat[key.toUpperCase()]) {965output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {966return val.slice(1);967});968this._longDateFormat[key] = output;969}970return output;971},972973isPM : function (input) {974// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays975// Using charAt should be more compatible.976return ((input + '').toLowerCase().charAt(0) === 'p');977},978979_meridiemParse : /[ap]\.?m?\.?/i,980meridiem : function (hours, minutes, isLower) {981if (hours > 11) {982return isLower ? 'pm' : 'PM';983} else {984return isLower ? 'am' : 'AM';985}986},987988989_calendar : {990sameDay : '[Today at] LT',991nextDay : '[Tomorrow at] LT',992nextWeek : 'dddd [at] LT',993lastDay : '[Yesterday at] LT',994lastWeek : '[Last] dddd [at] LT',995sameElse : 'L'996},997calendar : function (key, mom, now) {998var output = this._calendar[key];999return typeof output === 'function' ? output.apply(mom, [now]) : output;1000},10011002_relativeTime : {1003future : 'in %s',1004past : '%s ago',1005s : 'a few seconds',1006m : 'a minute',1007mm : '%d minutes',1008h : 'an hour',1009hh : '%d hours',1010d : 'a day',1011dd : '%d days',1012M : 'a month',1013MM : '%d months',1014y : 'a year',1015yy : '%d years'1016},10171018relativeTime : function (number, withoutSuffix, string, isFuture) {1019var output = this._relativeTime[string];1020return (typeof output === 'function') ?1021output(number, withoutSuffix, string, isFuture) :1022output.replace(/%d/i, number);1023},10241025pastFuture : function (diff, output) {1026var format = this._relativeTime[diff > 0 ? 'future' : 'past'];1027return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);1028},10291030ordinal : function (number) {1031return this._ordinal.replace('%d', number);1032},1033_ordinal : '%d',1034_ordinalParse : /\d{1,2}/,10351036preparse : function (string) {1037return string;1038},10391040postformat : function (string) {1041return string;1042},10431044week : function (mom) {1045return weekOfYear(mom, this._week.dow, this._week.doy).week;1046},10471048_week : {1049dow : 0, // Sunday is the first day of the week.1050doy : 6 // The week that contains Jan 1st is the first week of the year.1051},10521053firstDayOfWeek : function () {1054return this._week.dow;1055},10561057firstDayOfYear : function () {1058return this._week.doy;1059},10601061_invalidDate: 'Invalid date',1062invalidDate: function () {1063return this._invalidDate;1064}1065});10661067/************************************1068Formatting1069************************************/107010711072function removeFormattingTokens(input) {1073if (input.match(/\[[\s\S]/)) {1074return input.replace(/^\[|\]$/g, '');1075}1076return input.replace(/\\/g, '');1077}10781079function makeFormatFunction(format) {1080var array = format.match(formattingTokens), i, length;10811082for (i = 0, length = array.length; i < length; i++) {1083if (formatTokenFunctions[array[i]]) {1084array[i] = formatTokenFunctions[array[i]];1085} else {1086array[i] = removeFormattingTokens(array[i]);1087}1088}10891090return function (mom) {1091var output = '';1092for (i = 0; i < length; i++) {1093output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];1094}1095return output;1096};1097}10981099// format date using native date object1100function formatMoment(m, format) {1101if (!m.isValid()) {1102return m.localeData().invalidDate();1103}11041105format = expandFormat(format, m.localeData());11061107if (!formatFunctions[format]) {1108formatFunctions[format] = makeFormatFunction(format);1109}11101111return formatFunctions[format](m);1112}11131114function expandFormat(format, locale) {1115var i = 5;11161117function replaceLongDateFormatTokens(input) {1118return locale.longDateFormat(input) || input;1119}11201121localFormattingTokens.lastIndex = 0;1122while (i >= 0 && localFormattingTokens.test(format)) {1123format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);1124localFormattingTokens.lastIndex = 0;1125i -= 1;1126}11271128return format;1129}113011311132/************************************1133Parsing1134************************************/113511361137// get the regex to find the next token1138function getParseRegexForToken(token, config) {1139var a, strict = config._strict;1140switch (token) {1141case 'Q':1142return parseTokenOneDigit;1143case 'DDDD':1144return parseTokenThreeDigits;1145case 'YYYY':1146case 'GGGG':1147case 'gggg':1148return strict ? parseTokenFourDigits : parseTokenOneToFourDigits;1149case 'Y':1150case 'G':1151case 'g':1152return parseTokenSignedNumber;1153case 'YYYYYY':1154case 'YYYYY':1155case 'GGGGG':1156case 'ggggg':1157return strict ? parseTokenSixDigits : parseTokenOneToSixDigits;1158case 'S':1159if (strict) {1160return parseTokenOneDigit;1161}1162/* falls through */1163case 'SS':1164if (strict) {1165return parseTokenTwoDigits;1166}1167/* falls through */1168case 'SSS':1169if (strict) {1170return parseTokenThreeDigits;1171}1172/* falls through */1173case 'DDD':1174return parseTokenOneToThreeDigits;1175case 'MMM':1176case 'MMMM':1177case 'dd':1178case 'ddd':1179case 'dddd':1180return parseTokenWord;1181case 'a':1182case 'A':1183return config._locale._meridiemParse;1184case 'x':1185return parseTokenOffsetMs;1186case 'X':1187return parseTokenTimestampMs;1188case 'Z':1189case 'ZZ':1190return parseTokenTimezone;1191case 'T':1192return parseTokenT;1193case 'SSSS':1194return parseTokenDigits;1195case 'MM':1196case 'DD':1197case 'YY':1198case 'GG':1199case 'gg':1200case 'HH':1201case 'hh':1202case 'mm':1203case 'ss':1204case 'ww':1205case 'WW':1206return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits;1207case 'M':1208case 'D':1209case 'd':1210case 'H':1211case 'h':1212case 'm':1213case 's':1214case 'w':1215case 'W':1216case 'e':1217case 'E':1218return parseTokenOneOrTwoDigits;1219case 'Do':1220return strict ? config._locale._ordinalParse : config._locale._ordinalParseLenient;1221default :1222a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i'));1223return a;1224}1225}12261227function utcOffsetFromString(string) {1228string = string || '';1229var possibleTzMatches = (string.match(parseTokenTimezone) || []),1230tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [],1231parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0],1232minutes = +(parts[1] * 60) + toInt(parts[2]);12331234return parts[0] === '+' ? minutes : -minutes;1235}12361237// function to convert string input to date1238function addTimeToArrayFromToken(token, input, config) {1239var a, datePartArray = config._a;12401241switch (token) {1242// QUARTER1243case 'Q':1244if (input != null) {1245datePartArray[MONTH] = (toInt(input) - 1) * 3;1246}1247break;1248// MONTH1249case 'M' : // fall through to MM1250case 'MM' :1251if (input != null) {1252datePartArray[MONTH] = toInt(input) - 1;1253}1254break;1255case 'MMM' : // fall through to MMMM1256case 'MMMM' :1257a = config._locale.monthsParse(input, token, config._strict);1258// if we didn't find a month name, mark the date as invalid.1259if (a != null) {1260datePartArray[MONTH] = a;1261} else {1262config._pf.invalidMonth = input;1263}1264break;1265// DAY OF MONTH1266case 'D' : // fall through to DD1267case 'DD' :1268if (input != null) {1269datePartArray[DATE] = toInt(input);1270}1271break;1272case 'Do' :1273if (input != null) {1274datePartArray[DATE] = toInt(parseInt(1275input.match(/\d{1,2}/)[0], 10));1276}1277break;1278// DAY OF YEAR1279case 'DDD' : // fall through to DDDD1280case 'DDDD' :1281if (input != null) {1282config._dayOfYear = toInt(input);1283}12841285break;1286// YEAR1287case 'YY' :1288datePartArray[YEAR] = moment.parseTwoDigitYear(input);1289break;1290case 'YYYY' :1291case 'YYYYY' :1292case 'YYYYYY' :1293datePartArray[YEAR] = toInt(input);1294break;1295// AM / PM1296case 'a' : // fall through to A1297case 'A' :1298config._meridiem = input;1299// config._isPm = config._locale.isPM(input);1300break;1301// HOUR1302case 'h' : // fall through to hh1303case 'hh' :1304config._pf.bigHour = true;1305/* falls through */1306case 'H' : // fall through to HH1307case 'HH' :1308datePartArray[HOUR] = toInt(input);1309break;1310// MINUTE1311case 'm' : // fall through to mm1312case 'mm' :1313datePartArray[MINUTE] = toInt(input);1314break;1315// SECOND1316case 's' : // fall through to ss1317case 'ss' :1318datePartArray[SECOND] = toInt(input);1319break;1320// MILLISECOND1321case 'S' :1322case 'SS' :1323case 'SSS' :1324case 'SSSS' :1325datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000);1326break;1327// UNIX OFFSET (MILLISECONDS)1328case 'x':1329config._d = new Date(toInt(input));1330break;1331// UNIX TIMESTAMP WITH MS1332case 'X':1333config._d = new Date(parseFloat(input) * 1000);1334break;1335// TIMEZONE1336case 'Z' : // fall through to ZZ1337case 'ZZ' :1338config._useUTC = true;1339config._tzm = utcOffsetFromString(input);1340break;1341// WEEKDAY - human1342case 'dd':1343case 'ddd':1344case 'dddd':1345a = config._locale.weekdaysParse(input);1346// if we didn't get a weekday name, mark the date as invalid1347if (a != null) {1348config._w = config._w || {};1349config._w['d'] = a;1350} else {1351config._pf.invalidWeekday = input;1352}1353break;1354// WEEK, WEEK DAY - numeric1355case 'w':1356case 'ww':1357case 'W':1358case 'WW':1359case 'd':1360case 'e':1361case 'E':1362token = token.substr(0, 1);1363/* falls through */1364case 'gggg':1365case 'GGGG':1366case 'GGGGG':1367token = token.substr(0, 2);1368if (input) {1369config._w = config._w || {};1370config._w[token] = toInt(input);1371}1372break;1373case 'gg':1374case 'GG':1375config._w = config._w || {};1376config._w[token] = moment.parseTwoDigitYear(input);1377}1378}13791380function dayOfYearFromWeekInfo(config) {1381var w, weekYear, week, weekday, dow, doy, temp;13821383w = config._w;1384if (w.GG != null || w.W != null || w.E != null) {1385dow = 1;1386doy = 4;13871388// TODO: We need to take the current isoWeekYear, but that depends on1389// how we interpret now (local, utc, fixed offset). So create1390// a now version of current config (take local/utc/offset flags, and1391// create now).1392weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year);1393week = dfl(w.W, 1);1394weekday = dfl(w.E, 1);1395} else {1396dow = config._locale._week.dow;1397doy = config._locale._week.doy;13981399weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year);1400week = dfl(w.w, 1);14011402if (w.d != null) {1403// weekday -- low day numbers are considered next week1404weekday = w.d;1405if (weekday < dow) {1406++week;1407}1408} else if (w.e != null) {1409// local weekday -- counting starts from begining of week1410weekday = w.e + dow;1411} else {1412// default to begining of week1413weekday = dow;1414}1415}1416temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);14171418config._a[YEAR] = temp.year;1419config._dayOfYear = temp.dayOfYear;1420}14211422// convert an array to a date.1423// the array should mirror the parameters below1424// note: all values past the year are optional and will default to the lowest possible value.1425// [year, month, day , hour, minute, second, millisecond]1426function dateFromConfig(config) {1427var i, date, input = [], currentDate, yearToUse;14281429if (config._d) {1430return;1431}14321433currentDate = currentDateArray(config);14341435//compute day of the year from weeks and weekdays1436if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {1437dayOfYearFromWeekInfo(config);1438}14391440//if the day of the year is set, figure out what it is1441if (config._dayOfYear) {1442yearToUse = dfl(config._a[YEAR], currentDate[YEAR]);14431444if (config._dayOfYear > daysInYear(yearToUse)) {1445config._pf._overflowDayOfYear = true;1446}14471448date = makeUTCDate(yearToUse, 0, config._dayOfYear);1449config._a[MONTH] = date.getUTCMonth();1450config._a[DATE] = date.getUTCDate();1451}14521453// Default to current date.1454// * if no year, month, day of month are given, default to today1455// * if day of month is given, default month and year1456// * if month is given, default only year1457// * if year is given, don't default anything1458for (i = 0; i < 3 && config._a[i] == null; ++i) {1459config._a[i] = input[i] = currentDate[i];1460}14611462// Zero out whatever was not defaulted, including time1463for (; i < 7; i++) {1464config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];1465}14661467// Check for 24:00:00.0001468if (config._a[HOUR] === 24 &&1469config._a[MINUTE] === 0 &&1470config._a[SECOND] === 0 &&1471config._a[MILLISECOND] === 0) {1472config._nextDay = true;1473config._a[HOUR] = 0;1474}14751476config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);1477// Apply timezone offset from input. The actual utcOffset can be changed1478// with parseZone.1479if (config._tzm != null) {1480config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);1481}14821483if (config._nextDay) {1484config._a[HOUR] = 24;1485}1486}14871488function dateFromObject(config) {1489var normalizedInput;14901491if (config._d) {1492return;1493}14941495normalizedInput = normalizeObjectUnits(config._i);1496config._a = [1497normalizedInput.year,1498normalizedInput.month,1499normalizedInput.day || normalizedInput.date,1500normalizedInput.hour,1501normalizedInput.minute,1502normalizedInput.second,1503normalizedInput.millisecond1504];15051506dateFromConfig(config);1507}15081509function currentDateArray(config) {1510var now = new Date();1511if (config._useUTC) {1512return [1513now.getUTCFullYear(),1514now.getUTCMonth(),1515now.getUTCDate()1516];1517} else {1518return [now.getFullYear(), now.getMonth(), now.getDate()];1519}1520}15211522// date from string and format string1523function makeDateFromStringAndFormat(config) {1524if (config._f === moment.ISO_8601) {1525parseISO(config);1526return;1527}15281529config._a = [];1530config._pf.empty = true;15311532// This array is used to make a Date, either with `new Date` or `Date.UTC`1533var string = '' + config._i,1534i, parsedInput, tokens, token, skipped,1535stringLength = string.length,1536totalParsedInputLength = 0;15371538tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];15391540for (i = 0; i < tokens.length; i++) {1541token = tokens[i];1542parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];1543if (parsedInput) {1544skipped = string.substr(0, string.indexOf(parsedInput));1545if (skipped.length > 0) {1546config._pf.unusedInput.push(skipped);1547}1548string = string.slice(string.indexOf(parsedInput) + parsedInput.length);1549totalParsedInputLength += parsedInput.length;1550}1551// don't parse if it's not a known token1552if (formatTokenFunctions[token]) {1553if (parsedInput) {1554config._pf.empty = false;1555}1556else {1557config._pf.unusedTokens.push(token);1558}1559addTimeToArrayFromToken(token, parsedInput, config);1560}1561else if (config._strict && !parsedInput) {1562config._pf.unusedTokens.push(token);1563}1564}15651566// add remaining unparsed input length to the string1567config._pf.charsLeftOver = stringLength - totalParsedInputLength;1568if (string.length > 0) {1569config._pf.unusedInput.push(string);1570}15711572// clear _12h flag if hour is <= 121573if (config._pf.bigHour === true && config._a[HOUR] <= 12) {1574config._pf.bigHour = undefined;1575}1576// handle meridiem1577config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR],1578config._meridiem);1579dateFromConfig(config);1580checkOverflow(config);1581}15821583function unescapeFormat(s) {1584return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {1585return p1 || p2 || p3 || p4;1586});1587}15881589// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript1590function regexpEscape(s) {1591return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');1592}15931594// date from string and array of format strings1595function makeDateFromStringAndArray(config) {1596var tempConfig,1597bestMoment,15981599scoreToBeat,1600i,1601currentScore;16021603if (config._f.length === 0) {1604config._pf.invalidFormat = true;1605config._d = new Date(NaN);1606return;1607}16081609for (i = 0; i < config._f.length; i++) {1610currentScore = 0;1611tempConfig = copyConfig({}, config);1612if (config._useUTC != null) {1613tempConfig._useUTC = config._useUTC;1614}1615tempConfig._pf = defaultParsingFlags();1616tempConfig._f = config._f[i];1617makeDateFromStringAndFormat(tempConfig);16181619if (!isValid(tempConfig)) {1620continue;1621}16221623// if there is any input that was not parsed add a penalty for that format1624currentScore += tempConfig._pf.charsLeftOver;16251626//or tokens1627currentScore += tempConfig._pf.unusedTokens.length * 10;16281629tempConfig._pf.score = currentScore;16301631if (scoreToBeat == null || currentScore < scoreToBeat) {1632scoreToBeat = currentScore;1633bestMoment = tempConfig;1634}1635}16361637extend(config, bestMoment || tempConfig);1638}16391640// date from iso format1641function parseISO(config) {1642var i, l,1643string = config._i,1644match = isoRegex.exec(string);16451646if (match) {1647config._pf.iso = true;1648for (i = 0, l = isoDates.length; i < l; i++) {1649if (isoDates[i][1].exec(string)) {1650// match[5] should be 'T' or undefined1651config._f = isoDates[i][0] + (match[6] || ' ');1652break;1653}1654}1655for (i = 0, l = isoTimes.length; i < l; i++) {1656if (isoTimes[i][1].exec(string)) {1657config._f += isoTimes[i][0];1658break;1659}1660}1661if (string.match(parseTokenTimezone)) {1662config._f += 'Z';1663}1664makeDateFromStringAndFormat(config);1665} else {1666config._isValid = false;1667}1668}16691670// date from iso format or fallback1671function makeDateFromString(config) {1672parseISO(config);1673if (config._isValid === false) {1674delete config._isValid;1675moment.createFromInputFallback(config);1676}1677}16781679function map(arr, fn) {1680var res = [], i;1681for (i = 0; i < arr.length; ++i) {1682res.push(fn(arr[i], i));1683}1684return res;1685}16861687function makeDateFromInput(config) {1688var input = config._i, matched;1689if (input === undefined) {1690config._d = new Date();1691} else if (isDate(input)) {1692config._d = new Date(+input);1693} else if ((matched = aspNetJsonRegex.exec(input)) !== null) {1694config._d = new Date(+matched[1]);1695} else if (typeof input === 'string') {1696makeDateFromString(config);1697} else if (isArray(input)) {1698config._a = map(input.slice(0), function (obj) {1699return parseInt(obj, 10);1700});1701dateFromConfig(config);1702} else if (typeof(input) === 'object') {1703dateFromObject(config);1704} else if (typeof(input) === 'number') {1705// from milliseconds1706config._d = new Date(input);1707} else {1708moment.createFromInputFallback(config);1709}1710}17111712function makeDate(y, m, d, h, M, s, ms) {1713//can't just apply() to create a date:1714//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply1715var date = new Date(y, m, d, h, M, s, ms);17161717//the date constructor doesn't accept years < 19701718if (y < 1970) {1719date.setFullYear(y);1720}1721return date;1722}17231724function makeUTCDate(y) {1725var date = new Date(Date.UTC.apply(null, arguments));1726if (y < 1970) {1727date.setUTCFullYear(y);1728}1729return date;1730}17311732function parseWeekday(input, locale) {1733if (typeof input === 'string') {1734if (!isNaN(input)) {1735input = parseInt(input, 10);1736}1737else {1738input = locale.weekdaysParse(input);1739if (typeof input !== 'number') {1740return null;1741}1742}1743}1744return input;1745}17461747/************************************1748Relative Time1749************************************/175017511752// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize1753function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {1754return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);1755}17561757function relativeTime(posNegDuration, withoutSuffix, locale) {1758var duration = moment.duration(posNegDuration).abs(),1759seconds = round(duration.as('s')),1760minutes = round(duration.as('m')),1761hours = round(duration.as('h')),1762days = round(duration.as('d')),1763months = round(duration.as('M')),1764years = round(duration.as('y')),17651766args = seconds < relativeTimeThresholds.s && ['s', seconds] ||1767minutes === 1 && ['m'] ||1768minutes < relativeTimeThresholds.m && ['mm', minutes] ||1769hours === 1 && ['h'] ||1770hours < relativeTimeThresholds.h && ['hh', hours] ||1771days === 1 && ['d'] ||1772days < relativeTimeThresholds.d && ['dd', days] ||1773months === 1 && ['M'] ||1774months < relativeTimeThresholds.M && ['MM', months] ||1775years === 1 && ['y'] || ['yy', years];17761777args[2] = withoutSuffix;1778args[3] = +posNegDuration > 0;1779args[4] = locale;1780return substituteTimeAgo.apply({}, args);1781}178217831784/************************************1785Week of Year1786************************************/178717881789// firstDayOfWeek 0 = sun, 6 = sat1790// the day of the week that starts the week1791// (usually sunday or monday)1792// firstDayOfWeekOfYear 0 = sun, 6 = sat1793// the first week is the week that contains the first1794// of this day of the week1795// (eg. ISO weeks use thursday (4))1796function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {1797var end = firstDayOfWeekOfYear - firstDayOfWeek,1798daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),1799adjustedMoment;180018011802if (daysToDayOfWeek > end) {1803daysToDayOfWeek -= 7;1804}18051806if (daysToDayOfWeek < end - 7) {1807daysToDayOfWeek += 7;1808}18091810adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd');1811return {1812week: Math.ceil(adjustedMoment.dayOfYear() / 7),1813year: adjustedMoment.year()1814};1815}18161817//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday1818function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {1819var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;18201821d = d === 0 ? 7 : d;1822weekday = weekday != null ? weekday : firstDayOfWeek;1823daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);1824dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;18251826return {1827year: dayOfYear > 0 ? year : year - 1,1828dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear1829};1830}18311832/************************************1833Top Level Functions1834************************************/18351836function makeMoment(config) {1837var input = config._i,1838format = config._f,1839res;18401841config._locale = config._locale || moment.localeData(config._l);18421843if (input === null || (format === undefined && input === '')) {1844return moment.invalid({nullInput: true});1845}18461847if (typeof input === 'string') {1848config._i = input = config._locale.preparse(input);1849}18501851if (moment.isMoment(input)) {1852return new Moment(input, true);1853} else if (format) {1854if (isArray(format)) {1855makeDateFromStringAndArray(config);1856} else {1857makeDateFromStringAndFormat(config);1858}1859} else {1860makeDateFromInput(config);1861}18621863res = new Moment(config);1864if (res._nextDay) {1865// Adding is smart enough around DST1866res.add(1, 'd');1867res._nextDay = undefined;1868}18691870return res;1871}18721873moment = function (input, format, locale, strict) {1874var c;18751876if (typeof(locale) === 'boolean') {1877strict = locale;1878locale = undefined;1879}1880// object construction must be done this way.1881// https://github.com/moment/moment/issues/14231882c = {};1883c._isAMomentObject = true;1884c._i = input;1885c._f = format;1886c._l = locale;1887c._strict = strict;1888c._isUTC = false;1889c._pf = defaultParsingFlags();18901891return makeMoment(c);1892};18931894moment.suppressDeprecationWarnings = false;18951896moment.createFromInputFallback = deprecate(1897'moment construction falls back to js Date. This is ' +1898'discouraged and will be removed in upcoming major ' +1899'release. Please refer to ' +1900'https://github.com/moment/moment/issues/1407 for more info.',1901function (config) {1902config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));1903}1904);19051906// Pick a moment m from moments so that m[fn](other) is true for all1907// other. This relies on the function fn to be transitive.1908//1909// moments should either be an array of moment objects or an array, whose1910// first element is an array of moment objects.1911function pickBy(fn, moments) {1912var res, i;1913if (moments.length === 1 && isArray(moments[0])) {1914moments = moments[0];1915}1916if (!moments.length) {1917return moment();1918}1919res = moments[0];1920for (i = 1; i < moments.length; ++i) {1921if (moments[i][fn](res)) {1922res = moments[i];1923}1924}1925return res;1926}19271928moment.min = function () {1929var args = [].slice.call(arguments, 0);19301931return pickBy('isBefore', args);1932};19331934moment.max = function () {1935var args = [].slice.call(arguments, 0);19361937return pickBy('isAfter', args);1938};19391940// creating with utc1941moment.utc = function (input, format, locale, strict) {1942var c;19431944if (typeof(locale) === 'boolean') {1945strict = locale;1946locale = undefined;1947}1948// object construction must be done this way.1949// https://github.com/moment/moment/issues/14231950c = {};1951c._isAMomentObject = true;1952c._useUTC = true;1953c._isUTC = true;1954c._l = locale;1955c._i = input;1956c._f = format;1957c._strict = strict;1958c._pf = defaultParsingFlags();19591960return makeMoment(c).utc();1961};19621963// creating with unix timestamp (in seconds)1964moment.unix = function (input) {1965return moment(input * 1000);1966};19671968// duration1969moment.duration = function (input, key) {1970var duration = input,1971// matching against regexp is expensive, do it on demand1972match = null,1973sign,1974ret,1975parseIso,1976diffRes;19771978if (moment.isDuration(input)) {1979duration = {1980ms: input._milliseconds,1981d: input._days,1982M: input._months1983};1984} else if (typeof input === 'number') {1985duration = {};1986if (key) {1987duration[key] = input;1988} else {1989duration.milliseconds = input;1990}1991} else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {1992sign = (match[1] === '-') ? -1 : 1;1993duration = {1994y: 0,1995d: toInt(match[DATE]) * sign,1996h: toInt(match[HOUR]) * sign,1997m: toInt(match[MINUTE]) * sign,1998s: toInt(match[SECOND]) * sign,1999ms: toInt(match[MILLISECOND]) * sign2000};2001} else if (!!(match = isoDurationRegex.exec(input))) {2002sign = (match[1] === '-') ? -1 : 1;2003parseIso = function (inp) {2004// We'd normally use ~~inp for this, but unfortunately it also2005// converts floats to ints.2006// inp may be undefined, so careful calling replace on it.2007var res = inp && parseFloat(inp.replace(',', '.'));2008// apply sign while we're at it2009return (isNaN(res) ? 0 : res) * sign;2010};2011duration = {2012y: parseIso(match[2]),2013M: parseIso(match[3]),2014d: parseIso(match[4]),2015h: parseIso(match[5]),2016m: parseIso(match[6]),2017s: parseIso(match[7]),2018w: parseIso(match[8])2019};2020} else if (duration == null) {// checks for null or undefined2021duration = {};2022} else if (typeof duration === 'object' &&2023('from' in duration || 'to' in duration)) {2024diffRes = momentsDifference(moment(duration.from), moment(duration.to));20252026duration = {};2027duration.ms = diffRes.milliseconds;2028duration.M = diffRes.months;2029}20302031ret = new Duration(duration);20322033if (moment.isDuration(input) && hasOwnProp(input, '_locale')) {2034ret._locale = input._locale;2035}20362037return ret;2038};20392040// version number2041moment.version = VERSION;20422043// default format2044moment.defaultFormat = isoFormat;20452046// constant that refers to the ISO standard2047moment.ISO_8601 = function () {};20482049// Plugins that add properties should also add the key here (null value),2050// so we can properly clone ourselves.2051moment.momentProperties = momentProperties;20522053// This function will be called whenever a moment is mutated.2054// It is intended to keep the offset in sync with the timezone.2055moment.updateOffset = function () {};20562057// This function allows you to set a threshold for relative time strings2058moment.relativeTimeThreshold = function (threshold, limit) {2059if (relativeTimeThresholds[threshold] === undefined) {2060return false;2061}2062if (limit === undefined) {2063return relativeTimeThresholds[threshold];2064}2065relativeTimeThresholds[threshold] = limit;2066return true;2067};20682069moment.lang = deprecate(2070'moment.lang is deprecated. Use moment.locale instead.',2071function (key, value) {2072return moment.locale(key, value);2073}2074);20752076// This function will load locale and then set the global locale. If2077// no arguments are passed in, it will simply return the current global2078// locale key.2079moment.locale = function (key, values) {2080var data;2081if (key) {2082if (typeof(values) !== 'undefined') {2083data = moment.defineLocale(key, values);2084}2085else {2086data = moment.localeData(key);2087}20882089if (data) {2090moment.duration._locale = moment._locale = data;2091}2092}20932094return moment._locale._abbr;2095};20962097moment.defineLocale = function (name, values) {2098if (values !== null) {2099values.abbr = name;2100if (!locales[name]) {2101locales[name] = new Locale();2102}2103locales[name].set(values);21042105// backwards compat for now: also set the locale2106moment.locale(name);21072108return locales[name];2109} else {2110// useful for testing2111delete locales[name];2112return null;2113}2114};21152116moment.langData = deprecate(2117'moment.langData is deprecated. Use moment.localeData instead.',2118function (key) {2119return moment.localeData(key);2120}2121);21222123// returns locale data2124moment.localeData = function (key) {2125var locale;21262127if (key && key._locale && key._locale._abbr) {2128key = key._locale._abbr;2129}21302131if (!key) {2132return moment._locale;2133}21342135if (!isArray(key)) {2136//short-circuit everything else2137locale = loadLocale(key);2138if (locale) {2139return locale;2140}2141key = [key];2142}21432144return chooseLocale(key);2145};21462147// compare moment object2148moment.isMoment = function (obj) {2149return obj instanceof Moment ||2150(obj != null && hasOwnProp(obj, '_isAMomentObject'));2151};21522153// for typechecking Duration objects2154moment.isDuration = function (obj) {2155return obj instanceof Duration;2156};21572158for (i = lists.length - 1; i >= 0; --i) {2159makeList(lists[i]);2160}21612162moment.normalizeUnits = function (units) {2163return normalizeUnits(units);2164};21652166moment.invalid = function (flags) {2167var m = moment.utc(NaN);2168if (flags != null) {2169extend(m._pf, flags);2170}2171else {2172m._pf.userInvalidated = true;2173}21742175return m;2176};21772178moment.parseZone = function () {2179return moment.apply(null, arguments).parseZone();2180};21812182moment.parseTwoDigitYear = function (input) {2183return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);2184};21852186moment.isDate = isDate;21872188/************************************2189Moment Prototype2190************************************/219121922193extend(moment.fn = Moment.prototype, {21942195clone : function () {2196return moment(this);2197},21982199valueOf : function () {2200return +this._d - ((this._offset || 0) * 60000);2201},22022203unix : function () {2204return Math.floor(+this / 1000);2205},22062207toString : function () {2208return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');2209},22102211toDate : function () {2212return this._offset ? new Date(+this) : this._d;2213},22142215toISOString : function () {2216var m = moment(this).utc();2217if (0 < m.year() && m.year() <= 9999) {2218if ('function' === typeof Date.prototype.toISOString) {2219// native implementation is ~50x faster, use it when we can2220return this.toDate().toISOString();2221} else {2222return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');2223}2224} else {2225return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');2226}2227},22282229toArray : function () {2230var m = this;2231return [2232m.year(),2233m.month(),2234m.date(),2235m.hours(),2236m.minutes(),2237m.seconds(),2238m.milliseconds()2239];2240},22412242isValid : function () {2243return isValid(this);2244},22452246isDSTShifted : function () {2247if (this._a) {2248return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0;2249}22502251return false;2252},22532254parsingFlags : function () {2255return extend({}, this._pf);2256},22572258invalidAt: function () {2259return this._pf.overflow;2260},22612262utc : function (keepLocalTime) {2263return this.utcOffset(0, keepLocalTime);2264},22652266local : function (keepLocalTime) {2267if (this._isUTC) {2268this.utcOffset(0, keepLocalTime);2269this._isUTC = false;22702271if (keepLocalTime) {2272this.subtract(this._dateUtcOffset(), 'm');2273}2274}2275return this;2276},22772278format : function (inputString) {2279var output = formatMoment(this, inputString || moment.defaultFormat);2280return this.localeData().postformat(output);2281},22822283add : createAdder(1, 'add'),22842285subtract : createAdder(-1, 'subtract'),22862287diff : function (input, units, asFloat) {2288var that = makeAs(input, this),2289zoneDiff = (that.utcOffset() - this.utcOffset()) * 6e4,2290anchor, diff, output, daysAdjust;22912292units = normalizeUnits(units);22932294if (units === 'year' || units === 'month' || units === 'quarter') {2295output = monthDiff(this, that);2296if (units === 'quarter') {2297output = output / 3;2298} else if (units === 'year') {2299output = output / 12;2300}2301} else {2302diff = this - that;2303output = units === 'second' ? diff / 1e3 : // 10002304units === 'minute' ? diff / 6e4 : // 1000 * 602305units === 'hour' ? diff / 36e5 : // 1000 * 60 * 602306units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst2307units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst2308diff;2309}2310return asFloat ? output : absRound(output);2311},23122313from : function (time, withoutSuffix) {2314return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);2315},23162317fromNow : function (withoutSuffix) {2318return this.from(moment(), withoutSuffix);2319},23202321calendar : function (time) {2322// We want to compare the start of today, vs this.2323// Getting start-of-today depends on whether we're locat/utc/offset2324// or not.2325var now = time || moment(),2326sod = makeAs(now, this).startOf('day'),2327diff = this.diff(sod, 'days', true),2328format = diff < -6 ? 'sameElse' :2329diff < -1 ? 'lastWeek' :2330diff < 0 ? 'lastDay' :2331diff < 1 ? 'sameDay' :2332diff < 2 ? 'nextDay' :2333diff < 7 ? 'nextWeek' : 'sameElse';2334return this.format(this.localeData().calendar(format, this, moment(now)));2335},23362337isLeapYear : function () {2338return isLeapYear(this.year());2339},23402341isDST : function () {2342return (this.utcOffset() > this.clone().month(0).utcOffset() ||2343this.utcOffset() > this.clone().month(5).utcOffset());2344},23452346day : function (input) {2347var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();2348if (input != null) {2349input = parseWeekday(input, this.localeData());2350return this.add(input - day, 'd');2351} else {2352return day;2353}2354},23552356month : makeAccessor('Month', true),23572358startOf : function (units) {2359units = normalizeUnits(units);2360// the following switch intentionally omits break keywords2361// to utilize falling through the cases.2362switch (units) {2363case 'year':2364this.month(0);2365/* falls through */2366case 'quarter':2367case 'month':2368this.date(1);2369/* falls through */2370case 'week':2371case 'isoWeek':2372case 'day':2373this.hours(0);2374/* falls through */2375case 'hour':2376this.minutes(0);2377/* falls through */2378case 'minute':2379this.seconds(0);2380/* falls through */2381case 'second':2382this.milliseconds(0);2383/* falls through */2384}23852386// weeks are a special case2387if (units === 'week') {2388this.weekday(0);2389} else if (units === 'isoWeek') {2390this.isoWeekday(1);2391}23922393// quarters are also special2394if (units === 'quarter') {2395this.month(Math.floor(this.month() / 3) * 3);2396}23972398return this;2399},24002401endOf: function (units) {2402units = normalizeUnits(units);2403if (units === undefined || units === 'millisecond') {2404return this;2405}2406return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');2407},24082409isAfter: function (input, units) {2410var inputMs;2411units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');2412if (units === 'millisecond') {2413input = moment.isMoment(input) ? input : moment(input);2414return +this > +input;2415} else {2416inputMs = moment.isMoment(input) ? +input : +moment(input);2417return inputMs < +this.clone().startOf(units);2418}2419},24202421isBefore: function (input, units) {2422var inputMs;2423units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');2424if (units === 'millisecond') {2425input = moment.isMoment(input) ? input : moment(input);2426return +this < +input;2427} else {2428inputMs = moment.isMoment(input) ? +input : +moment(input);2429return +this.clone().endOf(units) < inputMs;2430}2431},24322433isBetween: function (from, to, units) {2434return this.isAfter(from, units) && this.isBefore(to, units);2435},24362437isSame: function (input, units) {2438var inputMs;2439units = normalizeUnits(units || 'millisecond');2440if (units === 'millisecond') {2441input = moment.isMoment(input) ? input : moment(input);2442return +this === +input;2443} else {2444inputMs = +moment(input);2445return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));2446}2447},24482449min: deprecate(2450'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',2451function (other) {2452other = moment.apply(null, arguments);2453return other < this ? this : other;2454}2455),24562457max: deprecate(2458'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',2459function (other) {2460other = moment.apply(null, arguments);2461return other > this ? this : other;2462}2463),24642465zone : deprecate(2466'moment().zone is deprecated, use moment().utcOffset instead. ' +2467'https://github.com/moment/moment/issues/1779',2468function (input, keepLocalTime) {2469if (input != null) {2470if (typeof input !== 'string') {2471input = -input;2472}24732474this.utcOffset(input, keepLocalTime);24752476return this;2477} else {2478return -this.utcOffset();2479}2480}2481),24822483// keepLocalTime = true means only change the timezone, without2484// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->2485// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset2486// +0200, so we adjust the time as needed, to be valid.2487//2488// Keeping the time actually adds/subtracts (one hour)2489// from the actual represented time. That is why we call updateOffset2490// a second time. In case it wants us to change the offset again2491// _changeInProgress == true case, then we have to adjust, because2492// there is no such time in the given timezone.2493utcOffset : function (input, keepLocalTime) {2494var offset = this._offset || 0,2495localAdjust;2496if (input != null) {2497if (typeof input === 'string') {2498input = utcOffsetFromString(input);2499}2500if (Math.abs(input) < 16) {2501input = input * 60;2502}2503if (!this._isUTC && keepLocalTime) {2504localAdjust = this._dateUtcOffset();2505}2506this._offset = input;2507this._isUTC = true;2508if (localAdjust != null) {2509this.add(localAdjust, 'm');2510}2511if (offset !== input) {2512if (!keepLocalTime || this._changeInProgress) {2513addOrSubtractDurationFromMoment(this,2514moment.duration(input - offset, 'm'), 1, false);2515} else if (!this._changeInProgress) {2516this._changeInProgress = true;2517moment.updateOffset(this, true);2518this._changeInProgress = null;2519}2520}25212522return this;2523} else {2524return this._isUTC ? offset : this._dateUtcOffset();2525}2526},25272528isLocal : function () {2529return !this._isUTC;2530},25312532isUtcOffset : function () {2533return this._isUTC;2534},25352536isUtc : function () {2537return this._isUTC && this._offset === 0;2538},25392540zoneAbbr : function () {2541return this._isUTC ? 'UTC' : '';2542},25432544zoneName : function () {2545return this._isUTC ? 'Coordinated Universal Time' : '';2546},25472548parseZone : function () {2549if (this._tzm) {2550this.utcOffset(this._tzm);2551} else if (typeof this._i === 'string') {2552this.utcOffset(utcOffsetFromString(this._i));2553}2554return this;2555},25562557hasAlignedHourOffset : function (input) {2558if (!input) {2559input = 0;2560}2561else {2562input = moment(input).utcOffset();2563}25642565return (this.utcOffset() - input) % 60 === 0;2566},25672568daysInMonth : function () {2569return daysInMonth(this.year(), this.month());2570},25712572dayOfYear : function (input) {2573var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;2574return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');2575},25762577quarter : function (input) {2578return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);2579},25802581weekYear : function (input) {2582var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;2583return input == null ? year : this.add((input - year), 'y');2584},25852586isoWeekYear : function (input) {2587var year = weekOfYear(this, 1, 4).year;2588return input == null ? year : this.add((input - year), 'y');2589},25902591week : function (input) {2592var week = this.localeData().week(this);2593return input == null ? week : this.add((input - week) * 7, 'd');2594},25952596isoWeek : function (input) {2597var week = weekOfYear(this, 1, 4).week;2598return input == null ? week : this.add((input - week) * 7, 'd');2599},26002601weekday : function (input) {2602var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;2603return input == null ? weekday : this.add(input - weekday, 'd');2604},26052606isoWeekday : function (input) {2607// behaves the same as moment#day except2608// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)2609// as a setter, sunday should belong to the previous week.2610return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);2611},26122613isoWeeksInYear : function () {2614return weeksInYear(this.year(), 1, 4);2615},26162617weeksInYear : function () {2618var weekInfo = this.localeData()._week;2619return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);2620},26212622get : function (units) {2623units = normalizeUnits(units);2624return this[units]();2625},26262627set : function (units, value) {2628var unit;2629if (typeof units === 'object') {2630for (unit in units) {2631this.set(unit, units[unit]);2632}2633}2634else {2635units = normalizeUnits(units);2636if (typeof this[units] === 'function') {2637this[units](value);2638}2639}2640return this;2641},26422643// If passed a locale key, it will set the locale for this2644// instance. Otherwise, it will return the locale configuration2645// variables for this instance.2646locale : function (key) {2647var newLocaleData;26482649if (key === undefined) {2650return this._locale._abbr;2651} else {2652newLocaleData = moment.localeData(key);2653if (newLocaleData != null) {2654this._locale = newLocaleData;2655}2656return this;2657}2658},26592660lang : deprecate(2661'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',2662function (key) {2663if (key === undefined) {2664return this.localeData();2665} else {2666return this.locale(key);2667}2668}2669),26702671localeData : function () {2672return this._locale;2673},26742675_dateUtcOffset : function () {2676// On Firefox.24 Date#getTimezoneOffset returns a floating point.2677// https://github.com/moment/moment/pull/18712678return -Math.round(this._d.getTimezoneOffset() / 15) * 15;2679}26802681});26822683function rawMonthSetter(mom, value) {2684var dayOfMonth;26852686// TODO: Move this out of here!2687if (typeof value === 'string') {2688value = mom.localeData().monthsParse(value);2689// TODO: Another silent failure?2690if (typeof value !== 'number') {2691return mom;2692}2693}26942695dayOfMonth = Math.min(mom.date(),2696daysInMonth(mom.year(), value));2697mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);2698return mom;2699}27002701function rawGetter(mom, unit) {2702return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();2703}27042705function rawSetter(mom, unit, value) {2706if (unit === 'Month') {2707return rawMonthSetter(mom, value);2708} else {2709return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);2710}2711}27122713function makeAccessor(unit, keepTime) {2714return function (value) {2715if (value != null) {2716rawSetter(this, unit, value);2717moment.updateOffset(this, keepTime);2718return this;2719} else {2720return rawGetter(this, unit);2721}2722};2723}27242725moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);2726moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);2727moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);2728// Setting the hour should keep the time, because the user explicitly2729// specified which hour he wants. So trying to maintain the same hour (in2730// a new timezone) makes sense. Adding/subtracting hours does not follow2731// this rule.2732moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);2733// moment.fn.month is defined separately2734moment.fn.date = makeAccessor('Date', true);2735moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true));2736moment.fn.year = makeAccessor('FullYear', true);2737moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true));27382739// add plural methods2740moment.fn.days = moment.fn.day;2741moment.fn.months = moment.fn.month;2742moment.fn.weeks = moment.fn.week;2743moment.fn.isoWeeks = moment.fn.isoWeek;2744moment.fn.quarters = moment.fn.quarter;27452746// add aliased format methods2747moment.fn.toJSON = moment.fn.toISOString;27482749// alias isUtc for dev-friendliness2750moment.fn.isUTC = moment.fn.isUtc;27512752/************************************2753Duration Prototype2754************************************/275527562757function daysToYears (days) {2758// 400 years have 146097 days (taking into account leap year rules)2759return days * 400 / 146097;2760}27612762function yearsToDays (years) {2763// years * 365 + absRound(years / 4) -2764// absRound(years / 100) + absRound(years / 400);2765return years * 146097 / 400;2766}27672768extend(moment.duration.fn = Duration.prototype, {27692770_bubble : function () {2771var milliseconds = this._milliseconds,2772days = this._days,2773months = this._months,2774data = this._data,2775seconds, minutes, hours, years = 0;27762777// The following code bubbles up values, see the tests for2778// examples of what that means.2779data.milliseconds = milliseconds % 1000;27802781seconds = absRound(milliseconds / 1000);2782data.seconds = seconds % 60;27832784minutes = absRound(seconds / 60);2785data.minutes = minutes % 60;27862787hours = absRound(minutes / 60);2788data.hours = hours % 24;27892790days += absRound(hours / 24);27912792// Accurately convert days to years, assume start from year 0.2793years = absRound(daysToYears(days));2794days -= absRound(yearsToDays(years));27952796// 30 days to a month2797// TODO (iskren): Use anchor date (like 1st Jan) to compute this.2798months += absRound(days / 30);2799days %= 30;28002801// 12 months -> 1 year2802years += absRound(months / 12);2803months %= 12;28042805data.days = days;2806data.months = months;2807data.years = years;2808},28092810abs : function () {2811this._milliseconds = Math.abs(this._milliseconds);2812this._days = Math.abs(this._days);2813this._months = Math.abs(this._months);28142815this._data.milliseconds = Math.abs(this._data.milliseconds);2816this._data.seconds = Math.abs(this._data.seconds);2817this._data.minutes = Math.abs(this._data.minutes);2818this._data.hours = Math.abs(this._data.hours);2819this._data.months = Math.abs(this._data.months);2820this._data.years = Math.abs(this._data.years);28212822return this;2823},28242825weeks : function () {2826return absRound(this.days() / 7);2827},28282829valueOf : function () {2830return this._milliseconds +2831this._days * 864e5 +2832(this._months % 12) * 2592e6 +2833toInt(this._months / 12) * 31536e6;2834},28352836humanize : function (withSuffix) {2837var output = relativeTime(this, !withSuffix, this.localeData());28382839if (withSuffix) {2840output = this.localeData().pastFuture(+this, output);2841}28422843return this.localeData().postformat(output);2844},28452846add : function (input, val) {2847// supports only 2.0-style add(1, 's') or add(moment)2848var dur = moment.duration(input, val);28492850this._milliseconds += dur._milliseconds;2851this._days += dur._days;2852this._months += dur._months;28532854this._bubble();28552856return this;2857},28582859subtract : function (input, val) {2860var dur = moment.duration(input, val);28612862this._milliseconds -= dur._milliseconds;2863this._days -= dur._days;2864this._months -= dur._months;28652866this._bubble();28672868return this;2869},28702871get : function (units) {2872units = normalizeUnits(units);2873return this[units.toLowerCase() + 's']();2874},28752876as : function (units) {2877var days, months;2878units = normalizeUnits(units);28792880if (units === 'month' || units === 'year') {2881days = this._days + this._milliseconds / 864e5;2882months = this._months + daysToYears(days) * 12;2883return units === 'month' ? months : months / 12;2884} else {2885// handle milliseconds separately because of floating point math errors (issue #1867)2886days = this._days + Math.round(yearsToDays(this._months / 12));2887switch (units) {2888case 'week': return days / 7 + this._milliseconds / 6048e5;2889case 'day': return days + this._milliseconds / 864e5;2890case 'hour': return days * 24 + this._milliseconds / 36e5;2891case 'minute': return days * 24 * 60 + this._milliseconds / 6e4;2892case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000;2893// Math.floor prevents floating point math errors here2894case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds;2895default: throw new Error('Unknown unit ' + units);2896}2897}2898},28992900lang : moment.fn.lang,2901locale : moment.fn.locale,29022903toIsoString : deprecate(2904'toIsoString() is deprecated. Please use toISOString() instead ' +2905'(notice the capitals)',2906function () {2907return this.toISOString();2908}2909),29102911toISOString : function () {2912// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js2913var years = Math.abs(this.years()),2914months = Math.abs(this.months()),2915days = Math.abs(this.days()),2916hours = Math.abs(this.hours()),2917minutes = Math.abs(this.minutes()),2918seconds = Math.abs(this.seconds() + this.milliseconds() / 1000);29192920if (!this.asSeconds()) {2921// this is the same as C#'s (Noda) and python (isodate)...2922// but not other JS (goog.date)2923return 'P0D';2924}29252926return (this.asSeconds() < 0 ? '-' : '') +2927'P' +2928(years ? years + 'Y' : '') +2929(months ? months + 'M' : '') +2930(days ? days + 'D' : '') +2931((hours || minutes || seconds) ? 'T' : '') +2932(hours ? hours + 'H' : '') +2933(minutes ? minutes + 'M' : '') +2934(seconds ? seconds + 'S' : '');2935},29362937localeData : function () {2938return this._locale;2939},29402941toJSON : function () {2942return this.toISOString();2943}2944});29452946moment.duration.fn.toString = moment.duration.fn.toISOString;29472948function makeDurationGetter(name) {2949moment.duration.fn[name] = function () {2950return this._data[name];2951};2952}29532954for (i in unitMillisecondFactors) {2955if (hasOwnProp(unitMillisecondFactors, i)) {2956makeDurationGetter(i.toLowerCase());2957}2958}29592960moment.duration.fn.asMilliseconds = function () {2961return this.as('ms');2962};2963moment.duration.fn.asSeconds = function () {2964return this.as('s');2965};2966moment.duration.fn.asMinutes = function () {2967return this.as('m');2968};2969moment.duration.fn.asHours = function () {2970return this.as('h');2971};2972moment.duration.fn.asDays = function () {2973return this.as('d');2974};2975moment.duration.fn.asWeeks = function () {2976return this.as('weeks');2977};2978moment.duration.fn.asMonths = function () {2979return this.as('M');2980};2981moment.duration.fn.asYears = function () {2982return this.as('y');2983};29842985/************************************2986Default Locale2987************************************/298829892990// Set default locale, other locale will inherit from English.2991moment.locale('en', {2992ordinalParse: /\d{1,2}(th|st|nd|rd)/,2993ordinal : function (number) {2994var b = number % 10,2995output = (toInt(number % 100 / 10) === 1) ? 'th' :2996(b === 1) ? 'st' :2997(b === 2) ? 'nd' :2998(b === 3) ? 'rd' : 'th';2999return number + output;3000}3001});30023003/* EMBED_LOCALES */30043005/************************************3006Exposing Moment3007************************************/30083009function makeGlobal(shouldDeprecate) {3010/*global ender:false */3011if (typeof ender !== 'undefined') {3012return;3013}3014oldGlobalMoment = globalScope.moment;3015if (shouldDeprecate) {3016globalScope.moment = deprecate(3017'Accessing Moment through the global scope is ' +3018'deprecated, and will be removed in an upcoming ' +3019'release.',3020moment);3021} else {3022globalScope.moment = moment;3023}3024}30253026// CommonJS module is defined3027if (hasModule) {3028module.exports = moment;3029} else if (typeof define === 'function' && define.amd) {3030define(function (require, exports, module) {3031if (module.config && module.config() && module.config().noGlobal === true) {3032// release the global variable3033globalScope.moment = oldGlobalMoment;3034}30353036return moment;3037});3038makeGlobal(true);3039} else {3040makeGlobal();3041}3042}).call(this);304330443045