Last active
February 11, 2024 23:32
-
-
Save brandonpittman/752350d333f114c6c830 to your computer and use it in GitHub Desktop.
TextExpander snippet to parse natural language into 'YYYY-MM-DD'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse(dateToParse) { | |
return chrono.parse(dateToParse) | |
} | |
function parseDate(dateToParse) { | |
return chrono.parseDate(dateToParse) | |
} | |
window = this; | |
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.chrono=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | |
(function (global){ | |
//! moment.js | |
//! version : 2.8.4 | |
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors | |
//! license : MIT | |
//! momentjs.com | |
(function (undefined) { | |
/************************************ | |
Constants | |
************************************/ | |
var moment, | |
VERSION = '2.8.4', | |
// the global-scope this is NOT the global object in Node.js | |
globalScope = typeof global !== 'undefined' ? global : this, | |
oldGlobalMoment, | |
round = Math.round, | |
hasOwnProperty = Object.prototype.hasOwnProperty, | |
i, | |
YEAR = 0, | |
MONTH = 1, | |
DATE = 2, | |
HOUR = 3, | |
MINUTE = 4, | |
SECOND = 5, | |
MILLISECOND = 6, | |
// internal storage for locale config files | |
locales = {}, | |
// extra moment internal properties (plugins register props here) | |
momentProperties = [], | |
// check for nodeJS | |
hasModule = (typeof module !== 'undefined' && module && module.exports), | |
// ASP.NET json date format regex | |
aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, | |
aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/, | |
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html | |
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere | |
isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/, | |
// format tokens | |
formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g, | |
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, | |
// parsing token regexes | |
parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 | |
parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 | |
parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999 | |
parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999 | |
parseTokenDigits = /\d+/, // nonzero number of digits | |
parseTokenWord = /[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. | |
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z | |
parseTokenT = /T/i, // T (ISO separator) | |
parseTokenOffsetMs = /[\+\-]?\d+/, // 1234567890123 | |
parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 | |
//strict parsing regexes | |
parseTokenOneDigit = /\d/, // 0 - 9 | |
parseTokenTwoDigits = /\d\d/, // 00 - 99 | |
parseTokenThreeDigits = /\d{3}/, // 000 - 999 | |
parseTokenFourDigits = /\d{4}/, // 0000 - 9999 | |
parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999 | |
parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf | |
// iso 8601 regex | |
// 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) | |
isoRegex = /^\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)?)?$/, | |
isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', | |
isoDates = [ | |
['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/], | |
['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/], | |
['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/], | |
['GGGG-[W]WW', /\d{4}-W\d{2}/], | |
['YYYY-DDD', /\d{4}-\d{3}/] | |
], | |
// iso time formats and regexes | |
isoTimes = [ | |
['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/], | |
['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], | |
['HH:mm', /(T| )\d\d:\d\d/], | |
['HH', /(T| )\d\d/] | |
], | |
// timezone chunker '+10:00' > ['10', '00'] or '-1530' > ['-15', '30'] | |
parseTimezoneChunker = /([\+\-]|\d\d)/gi, | |
// getter and setter names | |
proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'), | |
unitMillisecondFactors = { | |
'Milliseconds' : 1, | |
'Seconds' : 1e3, | |
'Minutes' : 6e4, | |
'Hours' : 36e5, | |
'Days' : 864e5, | |
'Months' : 2592e6, | |
'Years' : 31536e6 | |
}, | |
unitAliases = { | |
ms : 'millisecond', | |
s : 'second', | |
m : 'minute', | |
h : 'hour', | |
d : 'day', | |
D : 'date', | |
w : 'week', | |
W : 'isoWeek', | |
M : 'month', | |
Q : 'quarter', | |
y : 'year', | |
DDD : 'dayOfYear', | |
e : 'weekday', | |
E : 'isoWeekday', | |
gg: 'weekYear', | |
GG: 'isoWeekYear' | |
}, | |
camelFunctions = { | |
dayofyear : 'dayOfYear', | |
isoweekday : 'isoWeekday', | |
isoweek : 'isoWeek', | |
weekyear : 'weekYear', | |
isoweekyear : 'isoWeekYear' | |
}, | |
// format function strings | |
formatFunctions = {}, | |
// default relative time thresholds | |
relativeTimeThresholds = { | |
s: 45, // seconds to minute | |
m: 45, // minutes to hour | |
h: 22, // hours to day | |
d: 26, // days to month | |
M: 11 // months to year | |
}, | |
// tokens to ordinalize and pad | |
ordinalizeTokens = 'DDD w W M D d'.split(' '), | |
paddedTokens = 'M D H h m s w W'.split(' '), | |
formatTokenFunctions = { | |
M : function () { | |
return this.month() + 1; | |
}, | |
MMM : function (format) { | |
return this.localeData().monthsShort(this, format); | |
}, | |
MMMM : function (format) { | |
return this.localeData().months(this, format); | |
}, | |
D : function () { | |
return this.date(); | |
}, | |
DDD : function () { | |
return this.dayOfYear(); | |
}, | |
d : function () { | |
return this.day(); | |
}, | |
dd : function (format) { | |
return this.localeData().weekdaysMin(this, format); | |
}, | |
ddd : function (format) { | |
return this.localeData().weekdaysShort(this, format); | |
}, | |
dddd : function (format) { | |
return this.localeData().weekdays(this, format); | |
}, | |
w : function () { | |
return this.week(); | |
}, | |
W : function () { | |
return this.isoWeek(); | |
}, | |
YY : function () { | |
return leftZeroFill(this.year() % 100, 2); | |
}, | |
YYYY : function () { | |
return leftZeroFill(this.year(), 4); | |
}, | |
YYYYY : function () { | |
return leftZeroFill(this.year(), 5); | |
}, | |
YYYYYY : function () { | |
var y = this.year(), sign = y >= 0 ? '+' : '-'; | |
return sign + leftZeroFill(Math.abs(y), 6); | |
}, | |
gg : function () { | |
return leftZeroFill(this.weekYear() % 100, 2); | |
}, | |
gggg : function () { | |
return leftZeroFill(this.weekYear(), 4); | |
}, | |
ggggg : function () { | |
return leftZeroFill(this.weekYear(), 5); | |
}, | |
GG : function () { | |
return leftZeroFill(this.isoWeekYear() % 100, 2); | |
}, | |
GGGG : function () { | |
return leftZeroFill(this.isoWeekYear(), 4); | |
}, | |
GGGGG : function () { | |
return leftZeroFill(this.isoWeekYear(), 5); | |
}, | |
e : function () { | |
return this.weekday(); | |
}, | |
E : function () { | |
return this.isoWeekday(); | |
}, | |
a : function () { | |
return this.localeData().meridiem(this.hours(), this.minutes(), true); | |
}, | |
A : function () { | |
return this.localeData().meridiem(this.hours(), this.minutes(), false); | |
}, | |
H : function () { | |
return this.hours(); | |
}, | |
h : function () { | |
return this.hours() % 12 || 12; | |
}, | |
m : function () { | |
return this.minutes(); | |
}, | |
s : function () { | |
return this.seconds(); | |
}, | |
S : function () { | |
return toInt(this.milliseconds() / 100); | |
}, | |
SS : function () { | |
return leftZeroFill(toInt(this.milliseconds() / 10), 2); | |
}, | |
SSS : function () { | |
return leftZeroFill(this.milliseconds(), 3); | |
}, | |
SSSS : function () { | |
return leftZeroFill(this.milliseconds(), 3); | |
}, | |
Z : function () { | |
var a = -this.zone(), | |
b = '+'; | |
if (a < 0) { | |
a = -a; | |
b = '-'; | |
} | |
return b + leftZeroFill(toInt(a / 60), 2) + ':' + leftZeroFill(toInt(a) % 60, 2); | |
}, | |
ZZ : function () { | |
var a = -this.zone(), | |
b = '+'; | |
if (a < 0) { | |
a = -a; | |
b = '-'; | |
} | |
return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2); | |
}, | |
z : function () { | |
return this.zoneAbbr(); | |
}, | |
zz : function () { | |
return this.zoneName(); | |
}, | |
x : function () { | |
return this.valueOf(); | |
}, | |
X : function () { | |
return this.unix(); | |
}, | |
Q : function () { | |
return this.quarter(); | |
} | |
}, | |
deprecations = {}, | |
lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; | |
// Pick the first defined of two or three arguments. dfl comes from | |
// default. | |
function dfl(a, b, c) { | |
switch (arguments.length) { | |
case 2: return a != null ? a : b; | |
case 3: return a != null ? a : b != null ? b : c; | |
default: throw new Error('Implement me'); | |
} | |
} | |
function hasOwnProp(a, b) { | |
return hasOwnProperty.call(a, b); | |
} | |
function defaultParsingFlags() { | |
// We need to deep clone this object, and es5 standard is not very | |
// helpful. | |
return { | |
empty : false, | |
unusedTokens : [], | |
unusedInput : [], | |
overflow : -2, | |
charsLeftOver : 0, | |
nullInput : false, | |
invalidMonth : null, | |
invalidFormat : false, | |
userInvalidated : false, | |
iso: false | |
}; | |
} | |
function printMsg(msg) { | |
if (moment.suppressDeprecationWarnings === false && | |
typeof console !== 'undefined' && console.warn) { | |
console.warn('Deprecation warning: ' + msg); | |
} | |
} | |
function deprecate(msg, fn) { | |
var firstTime = true; | |
return extend(function () { | |
if (firstTime) { | |
printMsg(msg); | |
firstTime = false; | |
} | |
return fn.apply(this, arguments); | |
}, fn); | |
} | |
function deprecateSimple(name, msg) { | |
if (!deprecations[name]) { | |
printMsg(msg); | |
deprecations[name] = true; | |
} | |
} | |
function padToken(func, count) { | |
return function (a) { | |
return leftZeroFill(func.call(this, a), count); | |
}; | |
} | |
function ordinalizeToken(func, period) { | |
return function (a) { | |
return this.localeData().ordinal(func.call(this, a), period); | |
}; | |
} | |
while (ordinalizeTokens.length) { | |
i = ordinalizeTokens.pop(); | |
formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i); | |
} | |
while (paddedTokens.length) { | |
i = paddedTokens.pop(); | |
formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2); | |
} | |
formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3); | |
/************************************ | |
Constructors | |
************************************/ | |
function Locale() { | |
} | |
// Moment prototype object | |
function Moment(config, skipOverflow) { | |
if (skipOverflow !== false) { | |
checkOverflow(config); | |
} | |
copyConfig(this, config); | |
this._d = new Date(+config._d); | |
} | |
// Duration Constructor | |
function Duration(duration) { | |
var normalizedInput = normalizeObjectUnits(duration), | |
years = normalizedInput.year || 0, | |
quarters = normalizedInput.quarter || 0, | |
months = normalizedInput.month || 0, | |
weeks = normalizedInput.week || 0, | |
days = normalizedInput.day || 0, | |
hours = normalizedInput.hour || 0, | |
minutes = normalizedInput.minute || 0, | |
seconds = normalizedInput.second || 0, | |
milliseconds = normalizedInput.millisecond || 0; | |
// representation for dateAddRemove | |
this._milliseconds = +milliseconds + | |
seconds * 1e3 + // 1000 | |
minutes * 6e4 + // 1000 * 60 | |
hours * 36e5; // 1000 * 60 * 60 | |
// Because of dateAddRemove treats 24 hours as different from a | |
// day when working around DST, we need to store them separately | |
this._days = +days + | |
weeks * 7; | |
// It is impossible translate months into days without knowing | |
// which months you are are talking about, so we have to store | |
// it separately. | |
this._months = +months + | |
quarters * 3 + | |
years * 12; | |
this._data = {}; | |
this._locale = moment.localeData(); | |
this._bubble(); | |
} | |
/************************************ | |
Helpers | |
************************************/ | |
function extend(a, b) { | |
for (var i in b) { | |
if (hasOwnProp(b, i)) { | |
a[i] = b[i]; | |
} | |
} | |
if (hasOwnProp(b, 'toString')) { | |
a.toString = b.toString; | |
} | |
if (hasOwnProp(b, 'valueOf')) { | |
a.valueOf = b.valueOf; | |
} | |
return a; | |
} | |
function copyConfig(to, from) { | |
var i, prop, val; | |
if (typeof from._isAMomentObject !== 'undefined') { | |
to._isAMomentObject = from._isAMomentObject; | |
} | |
if (typeof from._i !== 'undefined') { | |
to._i = from._i; | |
} | |
if (typeof from._f !== 'undefined') { | |
to._f = from._f; | |
} | |
if (typeof from._l !== 'undefined') { | |
to._l = from._l; | |
} | |
if (typeof from._strict !== 'undefined') { | |
to._strict = from._strict; | |
} | |
if (typeof from._tzm !== 'undefined') { | |
to._tzm = from._tzm; | |
} | |
if (typeof from._isUTC !== 'undefined') { | |
to._isUTC = from._isUTC; | |
} | |
if (typeof from._offset !== 'undefined') { | |
to._offset = from._offset; | |
} | |
if (typeof from._pf !== 'undefined') { | |
to._pf = from._pf; | |
} | |
if (typeof from._locale !== 'undefined') { | |
to._locale = from._locale; | |
} | |
if (momentProperties.length > 0) { | |
for (i in momentProperties) { | |
prop = momentProperties[i]; | |
val = from[prop]; | |
if (typeof val !== 'undefined') { | |
to[prop] = val; | |
} | |
} | |
} | |
return to; | |
} | |
function absRound(number) { | |
if (number < 0) { | |
return Math.ceil(number); | |
} else { | |
return Math.floor(number); | |
} | |
} | |
// left zero fill a number | |
// see http://jsperf.com/left-zero-filling for performance comparison | |
function leftZeroFill(number, targetLength, forceSign) { | |
var output = '' + Math.abs(number), | |
sign = number >= 0; | |
while (output.length < targetLength) { | |
output = '0' + output; | |
} | |
return (sign ? (forceSign ? '+' : '') : '-') + output; | |
} | |
function positiveMomentsDifference(base, other) { | |
var res = {milliseconds: 0, months: 0}; | |
res.months = other.month() - base.month() + | |
(other.year() - base.year()) * 12; | |
if (base.clone().add(res.months, 'M').isAfter(other)) { | |
--res.months; | |
} | |
res.milliseconds = +other - +(base.clone().add(res.months, 'M')); | |
return res; | |
} | |
function momentsDifference(base, other) { | |
var res; | |
other = makeAs(other, base); | |
if (base.isBefore(other)) { | |
res = positiveMomentsDifference(base, other); | |
} else { | |
res = positiveMomentsDifference(other, base); | |
res.milliseconds = -res.milliseconds; | |
res.months = -res.months; | |
} | |
return res; | |
} | |
// TODO: remove 'name' arg after deprecation is removed | |
function createAdder(direction, name) { | |
return function (val, period) { | |
var dur, tmp; | |
//invert the arguments, but complain about it | |
if (period !== null && !isNaN(+period)) { | |
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).'); | |
tmp = val; val = period; period = tmp; | |
} | |
val = typeof val === 'string' ? +val : val; | |
dur = moment.duration(val, period); | |
addOrSubtractDurationFromMoment(this, dur, direction); | |
return this; | |
}; | |
} | |
function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) { | |
var milliseconds = duration._milliseconds, | |
days = duration._days, | |
months = duration._months; | |
updateOffset = updateOffset == null ? true : updateOffset; | |
if (milliseconds) { | |
mom._d.setTime(+mom._d + milliseconds * isAdding); | |
} | |
if (days) { | |
rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding); | |
} | |
if (months) { | |
rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding); | |
} | |
if (updateOffset) { | |
moment.updateOffset(mom, days || months); | |
} | |
} | |
// check if is an array | |
function isArray(input) { | |
return Object.prototype.toString.call(input) === '[object Array]'; | |
} | |
function isDate(input) { | |
return Object.prototype.toString.call(input) === '[object Date]' || | |
input instanceof Date; | |
} | |
// compare two arrays, return the number of differences | |
function compareArrays(array1, array2, dontConvert) { | |
var len = Math.min(array1.length, array2.length), | |
lengthDiff = Math.abs(array1.length - array2.length), | |
diffs = 0, | |
i; | |
for (i = 0; i < len; i++) { | |
if ((dontConvert && array1[i] !== array2[i]) || | |
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { | |
diffs++; | |
} | |
} | |
return diffs + lengthDiff; | |
} | |
function normalizeUnits(units) { | |
if (units) { | |
var lowered = units.toLowerCase().replace(/(.)s$/, '$1'); | |
units = unitAliases[units] || camelFunctions[lowered] || lowered; | |
} | |
return units; | |
} | |
function normalizeObjectUnits(inputObject) { | |
var normalizedInput = {}, | |
normalizedProp, | |
prop; | |
for (prop in inputObject) { | |
if (hasOwnProp(inputObject, prop)) { | |
normalizedProp = normalizeUnits(prop); | |
if (normalizedProp) { | |
normalizedInput[normalizedProp] = inputObject[prop]; | |
} | |
} | |
} | |
return normalizedInput; | |
} | |
function makeList(field) { | |
var count, setter; | |
if (field.indexOf('week') === 0) { | |
count = 7; | |
setter = 'day'; | |
} | |
else if (field.indexOf('month') === 0) { | |
count = 12; | |
setter = 'month'; | |
} | |
else { | |
return; | |
} | |
moment[field] = function (format, index) { | |
var i, getter, | |
method = moment._locale[field], | |
results = []; | |
if (typeof format === 'number') { | |
index = format; | |
format = undefined; | |
} | |
getter = function (i) { | |
var m = moment().utc().set(setter, i); | |
return method.call(moment._locale, m, format || ''); | |
}; | |
if (index != null) { | |
return getter(index); | |
} | |
else { | |
for (i = 0; i < count; i++) { | |
results.push(getter(i)); | |
} | |
return results; | |
} | |
}; | |
} | |
function toInt(argumentForCoercion) { | |
var coercedNumber = +argumentForCoercion, | |
value = 0; | |
if (coercedNumber !== 0 && isFinite(coercedNumber)) { | |
if (coercedNumber >= 0) { | |
value = Math.floor(coercedNumber); | |
} else { | |
value = Math.ceil(coercedNumber); | |
} | |
} | |
return value; | |
} | |
function daysInMonth(year, month) { | |
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); | |
} | |
function weeksInYear(year, dow, doy) { | |
return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week; | |
} | |
function daysInYear(year) { | |
return isLeapYear(year) ? 366 : 365; | |
} | |
function isLeapYear(year) { | |
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; | |
} | |
function checkOverflow(m) { | |
var overflow; | |
if (m._a && m._pf.overflow === -2) { | |
overflow = | |
m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH : | |
m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE : | |
m._a[HOUR] < 0 || m._a[HOUR] > 24 || | |
(m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 || | |
m._a[SECOND] !== 0 || | |
m._a[MILLISECOND] !== 0)) ? HOUR : | |
m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE : | |
m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND : | |
m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND : | |
-1; | |
if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { | |
overflow = DATE; | |
} | |
m._pf.overflow = overflow; | |
} | |
} | |
function isValid(m) { | |
if (m._isValid == null) { | |
m._isValid = !isNaN(m._d.getTime()) && | |
m._pf.overflow < 0 && | |
!m._pf.empty && | |
!m._pf.invalidMonth && | |
!m._pf.nullInput && | |
!m._pf.invalidFormat && | |
!m._pf.userInvalidated; | |
if (m._strict) { | |
m._isValid = m._isValid && | |
m._pf.charsLeftOver === 0 && | |
m._pf.unusedTokens.length === 0 && | |
m._pf.bigHour === undefined; | |
} | |
} | |
return m._isValid; | |
} | |
function normalizeLocale(key) { | |
return key ? key.toLowerCase().replace('_', '-') : key; | |
} | |
// pick the locale from the array | |
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each | |
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root | |
function chooseLocale(names) { | |
var i = 0, j, next, locale, split; | |
while (i < names.length) { | |
split = normalizeLocale(names[i]).split('-'); | |
j = split.length; | |
next = normalizeLocale(names[i + 1]); | |
next = next ? next.split('-') : null; | |
while (j > 0) { | |
locale = loadLocale(split.slice(0, j).join('-')); | |
if (locale) { | |
return locale; | |
} | |
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { | |
//the next array item is better than a shallower substring of this one | |
break; | |
} | |
j--; | |
} | |
i++; | |
} | |
return null; | |
} | |
function loadLocale(name) { | |
var oldLocale = null; | |
if (!locales[name] && hasModule) { | |
try { | |
oldLocale = moment.locale(); | |
require('./locale/' + name); | |
// because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales | |
moment.locale(oldLocale); | |
} catch (e) { } | |
} | |
return locales[name]; | |
} | |
// Return a moment from input, that is local/utc/zone equivalent to model. | |
function makeAs(input, model) { | |
var res, diff; | |
if (model._isUTC) { | |
res = model.clone(); | |
diff = (moment.isMoment(input) || isDate(input) ? | |
+input : +moment(input)) - (+res); | |
// Use low-level api, because this fn is low-level api. | |
res._d.setTime(+res._d + diff); | |
moment.updateOffset(res, false); | |
return res; | |
} else { | |
return moment(input).local(); | |
} | |
} | |
/************************************ | |
Locale | |
************************************/ | |
extend(Locale.prototype, { | |
set : function (config) { | |
var prop, i; | |
for (i in config) { | |
prop = config[i]; | |
if (typeof prop === 'function') { | |
this[i] = prop; | |
} else { | |
this['_' + i] = prop; | |
} | |
} | |
// Lenient ordinal parsing accepts just a number in addition to | |
// number + (possibly) stuff coming from _ordinalParseLenient. | |
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source); | |
}, | |
_months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), | |
months : function (m) { | |
return this._months[m.month()]; | |
}, | |
_monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), | |
monthsShort : function (m) { | |
return this._monthsShort[m.month()]; | |
}, | |
monthsParse : function (monthName, format, strict) { | |
var i, mom, regex; | |
if (!this._monthsParse) { | |
this._monthsParse = []; | |
this._longMonthsParse = []; | |
this._shortMonthsParse = []; | |
} | |
for (i = 0; i < 12; i++) { | |
// make the regex if we don't have it already | |
mom = moment.utc([2000, i]); | |
if (strict && !this._longMonthsParse[i]) { | |
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); | |
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i'); | |
} | |
if (!strict && !this._monthsParse[i]) { | |
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); | |
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); | |
} | |
// test the regex | |
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { | |
return i; | |
} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { | |
return i; | |
} else if (!strict && this._monthsParse[i].test(monthName)) { | |
return i; | |
} | |
} | |
}, | |
_weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), | |
weekdays : function (m) { | |
return this._weekdays[m.day()]; | |
}, | |
_weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), | |
weekdaysShort : function (m) { | |
return this._weekdaysShort[m.day()]; | |
}, | |
_weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), | |
weekdaysMin : function (m) { | |
return this._weekdaysMin[m.day()]; | |
}, | |
weekdaysParse : function (weekdayName) { | |
var i, mom, regex; | |
if (!this._weekdaysParse) { | |
this._weekdaysParse = []; | |
} | |
for (i = 0; i < 7; i++) { | |
// make the regex if we don't have it already | |
if (!this._weekdaysParse[i]) { | |
mom = moment([2000, 1]).day(i); | |
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); | |
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); | |
} | |
// test the regex | |
if (this._weekdaysParse[i].test(weekdayName)) { | |
return i; | |
} | |
} | |
}, | |
_longDateFormat : { | |
LTS : 'h:mm:ss A', | |
LT : 'h:mm A', | |
L : 'MM/DD/YYYY', | |
LL : 'MMMM D, YYYY', | |
LLL : 'MMMM D, YYYY LT', | |
LLLL : 'dddd, MMMM D, YYYY LT' | |
}, | |
longDateFormat : function (key) { | |
var output = this._longDateFormat[key]; | |
if (!output && this._longDateFormat[key.toUpperCase()]) { | |
output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { | |
return val.slice(1); | |
}); | |
this._longDateFormat[key] = output; | |
} | |
return output; | |
}, | |
isPM : function (input) { | |
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays | |
// Using charAt should be more compatible. | |
return ((input + '').toLowerCase().charAt(0) === 'p'); | |
}, | |
_meridiemParse : /[ap]\.?m?\.?/i, | |
meridiem : function (hours, minutes, isLower) { | |
if (hours > 11) { | |
return isLower ? 'pm' : 'PM'; | |
} else { | |
return isLower ? 'am' : 'AM'; | |
} | |
}, | |
_calendar : { | |
sameDay : '[Today at] LT', | |
nextDay : '[Tomorrow at] LT', | |
nextWeek : 'dddd [at] LT', | |
lastDay : '[Yesterday at] LT', | |
lastWeek : '[Last] dddd [at] LT', | |
sameElse : 'L' | |
}, | |
calendar : function (key, mom, now) { | |
var output = this._calendar[key]; | |
return typeof output === 'function' ? output.apply(mom, [now]) : output; | |
}, | |
_relativeTime : { | |
future : 'in %s', | |
past : '%s ago', | |
s : 'a few seconds', | |
m : 'a minute', | |
mm : '11 minutes', | |
h : 'an hour', | |
hh : '11 hours', | |
d : 'a day', | |
dd : '11 days', | |
M : 'a month', | |
MM : '11 months', | |
y : 'a year', | |
yy : '11 years' | |
}, | |
relativeTime : function (number, withoutSuffix, string, isFuture) { | |
var output = this._relativeTime[string]; | |
return (typeof output === 'function') ? | |
output(number, withoutSuffix, string, isFuture) : | |
output.replace(/11/i, number); | |
}, | |
pastFuture : function (diff, output) { | |
var format = this._relativeTime[diff > 0 ? 'future' : 'past']; | |
return typeof format === 'function' ? format(output) : format.replace(/%s/i, output); | |
}, | |
ordinal : function (number) { | |
return this._ordinal.replace('11', number); | |
}, | |
_ordinal : '11', | |
_ordinalParse : /\d{1,2}/, | |
preparse : function (string) { | |
return string; | |
}, | |
postformat : function (string) { | |
return string; | |
}, | |
week : function (mom) { | |
return weekOfYear(mom, this._week.dow, this._week.doy).week; | |
}, | |
_week : { | |
dow : 0, // Sunday is the first day of the week. | |
doy : 6 // The week that contains Jan 1st is the first week of the year. | |
}, | |
_invalidDate: 'Invalid date', | |
invalidDate: function () { | |
return this._invalidDate; | |
} | |
}); | |
/************************************ | |
Formatting | |
************************************/ | |
function removeFormattingTokens(input) { | |
if (input.match(/\[[\s\S]/)) { | |
return input.replace(/^\[|\]$/g, ''); | |
} | |
return input.replace(/\\/g, ''); | |
} | |
function makeFormatFunction(format) { | |
var array = format.match(formattingTokens), i, length; | |
for (i = 0, length = array.length; i < length; i++) { | |
if (formatTokenFunctions[array[i]]) { | |
array[i] = formatTokenFunctions[array[i]]; | |
} else { | |
array[i] = removeFormattingTokens(array[i]); | |
} | |
} | |
return function (mom) { | |
var output = ''; | |
for (i = 0; i < length; i++) { | |
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; | |
} | |
return output; | |
}; | |
} | |
// format date using native date object | |
function formatMoment(m, format) { | |
if (!m.isValid()) { | |
return m.localeData().invalidDate(); | |
} | |
format = expandFormat(format, m.localeData()); | |
if (!formatFunctions[format]) { | |
formatFunctions[format] = makeFormatFunction(format); | |
} | |
return formatFunctions[format](m); | |
} | |
function expandFormat(format, locale) { | |
var i = 5; | |
function replaceLongDateFormatTokens(input) { | |
return locale.longDateFormat(input) || input; | |
} | |
localFormattingTokens.lastIndex = 0; | |
while (i >= 0 && localFormattingTokens.test(format)) { | |
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); | |
localFormattingTokens.lastIndex = 0; | |
i -= 1; | |
} | |
return format; | |
} | |
/************************************ | |
Parsing | |
************************************/ | |
// get the regex to find the next token | |
function getParseRegexForToken(token, config) { | |
var a, strict = config._strict; | |
switch (token) { | |
case 'Q': | |
return parseTokenOneDigit; | |
case 'DDDD': | |
return parseTokenThreeDigits; | |
case 'YYYY': | |
case 'GGGG': | |
case 'gggg': | |
return strict ? parseTokenFourDigits : parseTokenOneToFourDigits; | |
case 'Y': | |
case 'G': | |
case 'g': | |
return parseTokenSignedNumber; | |
case 'YYYYYY': | |
case 'YYYYY': | |
case 'GGGGG': | |
case 'ggggg': | |
return strict ? parseTokenSixDigits : parseTokenOneToSixDigits; | |
case 'S': | |
if (strict) { | |
return parseTokenOneDigit; | |
} | |
/* falls through */ | |
case 'SS': | |
if (strict) { | |
return parseTokenTwoDigits; | |
} | |
/* falls through */ | |
case 'SSS': | |
if (strict) { | |
return parseTokenThreeDigits; | |
} | |
/* falls through */ | |
case 'DDD': | |
return parseTokenOneToThreeDigits; | |
case 'MMM': | |
case 'MMMM': | |
case 'dd': | |
case 'ddd': | |
case 'dddd': | |
return parseTokenWord; | |
case 'a': | |
case 'A': | |
return config._locale._meridiemParse; | |
case 'x': | |
return parseTokenOffsetMs; | |
case 'X': | |
return parseTokenTimestampMs; | |
case 'Z': | |
case 'ZZ': | |
return parseTokenTimezone; | |
case 'T': | |
return parseTokenT; | |
case 'SSSS': | |
return parseTokenDigits; | |
case 'MM': | |
case 'DD': | |
case 'YY': | |
case 'GG': | |
case 'gg': | |
case 'HH': | |
case 'hh': | |
case 'mm': | |
case 'ss': | |
case 'ww': | |
case 'WW': | |
return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits; | |
case 'M': | |
case 'D': | |
case 'd': | |
case 'H': | |
case 'h': | |
case 'm': | |
case 's': | |
case 'w': | |
case 'W': | |
case 'e': | |
case 'E': | |
return parseTokenOneOrTwoDigits; | |
case 'Do': | |
return strict ? config._locale._ordinalParse : config._locale._ordinalParseLenient; | |
default : | |
a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), 'i')); | |
return a; | |
} | |
} | |
function timezoneMinutesFromString(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; | |
} | |
// function to convert string input to date | |
function addTimeToArrayFromToken(token, input, config) { | |
var a, datePartArray = config._a; | |
switch (token) { | |
// QUARTER | |
case 'Q': | |
if (input != null) { | |
datePartArray[MONTH] = (toInt(input) - 1) * 3; | |
} | |
break; | |
// MONTH | |
case 'M' : // fall through to MM | |
case 'MM' : | |
if (input != null) { | |
datePartArray[MONTH] = toInt(input) - 1; | |
} | |
break; | |
case 'MMM' : // fall through to MMMM | |
case 'MMMM' : | |
a = config._locale.monthsParse(input, token, config._strict); | |
// if we didn't find a month name, mark the date as invalid. | |
if (a != null) { | |
datePartArray[MONTH] = a; | |
} else { | |
config._pf.invalidMonth = input; | |
} | |
break; | |
// DAY OF MONTH | |
case 'D' : // fall through to DD | |
case 'DD' : | |
if (input != null) { | |
datePartArray[DATE] = toInt(input); | |
} | |
break; | |
case 'Do' : | |
if (input != null) { | |
datePartArray[DATE] = toInt(parseInt( | |
input.match(/\d{1,2}/)[0], 10)); | |
} | |
break; | |
// DAY OF YEAR | |
case 'DDD' : // fall through to DDDD | |
case 'DDDD' : | |
if (input != null) { | |
config._dayOfYear = toInt(input); | |
} | |
break; | |
// YEAR | |
case 'YY' : | |
datePartArray[YEAR] = moment.parseTwoDigitYear(input); | |
break; | |
case 'YYYY' : | |
case 'YYYYY' : | |
case 'YYYYYY' : | |
datePartArray[YEAR] = toInt(input); | |
break; | |
// AM / PM | |
case 'a' : // fall through to A | |
case 'A' : | |
config._isPm = config._locale.isPM(input); | |
break; | |
// HOUR | |
case 'h' : // fall through to hh | |
case 'hh' : | |
config._pf.bigHour = true; | |
/* falls through */ | |
case 'H' : // fall through to HH | |
case 'HH' : | |
datePartArray[HOUR] = toInt(input); | |
break; | |
// MINUTE | |
case 'm' : // fall through to mm | |
case 'mm' : | |
datePartArray[MINUTE] = toInt(input); | |
break; | |
// SECOND | |
case 's' : // fall through to ss | |
case 'ss' : | |
datePartArray[SECOND] = toInt(input); | |
break; | |
// MILLISECOND | |
case 'S' : | |
case 'SS' : | |
case 'SSS' : | |
case 'SSSS' : | |
datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000); | |
break; | |
// UNIX OFFSET (MILLISECONDS) | |
case 'x': | |
config._d = new Date(toInt(input)); | |
break; | |
// UNIX TIMESTAMP WITH MS | |
case 'X': | |
config._d = new Date(parseFloat(input) * 1000); | |
break; | |
// TIMEZONE | |
case 'Z' : // fall through to ZZ | |
case 'ZZ' : | |
config._useUTC = true; | |
config._tzm = timezoneMinutesFromString(input); | |
break; | |
// WEEKDAY - human | |
case 'dd': | |
case 'ddd': | |
case 'dddd': | |
a = config._locale.weekdaysParse(input); | |
// if we didn't get a weekday name, mark the date as invalid | |
if (a != null) { | |
config._w = config._w || {}; | |
config._w['d'] = a; | |
} else { | |
config._pf.invalidWeekday = input; | |
} | |
break; | |
// WEEK, WEEK DAY - numeric | |
case 'w': | |
case 'ww': | |
case 'W': | |
case 'WW': | |
case 'd': | |
case 'e': | |
case 'E': | |
token = token.substr(0, 1); | |
/* falls through */ | |
case 'gggg': | |
case 'GGGG': | |
case 'GGGGG': | |
token = token.substr(0, 2); | |
if (input) { | |
config._w = config._w || {}; | |
config._w[token] = toInt(input); | |
} | |
break; | |
case 'gg': | |
case 'GG': | |
config._w = config._w || {}; | |
config._w[token] = moment.parseTwoDigitYear(input); | |
} | |
} | |
function dayOfYearFromWeekInfo(config) { | |
var w, weekYear, week, weekday, dow, doy, temp; | |
w = config._w; | |
if (w.GG != null || w.W != null || w.E != null) { | |
dow = 1; | |
doy = 4; | |
// TODO: We need to take the current isoWeekYear, but that depends on | |
// how we interpret now (local, utc, fixed offset). So create | |
// a now version of current config (take local/utc/offset flags, and | |
// create now). | |
weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year); | |
week = dfl(w.W, 1); | |
weekday = dfl(w.E, 1); | |
} else { | |
dow = config._locale._week.dow; | |
doy = config._locale._week.doy; | |
weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year); | |
week = dfl(w.w, 1); | |
if (w.d != null) { | |
// weekday -- low day numbers are considered next week | |
weekday = w.d; | |
if (weekday < dow) { | |
++week; | |
} | |
} else if (w.e != null) { | |
// local weekday -- counting starts from begining of week | |
weekday = w.e + dow; | |
} else { | |
// default to begining of week | |
weekday = dow; | |
} | |
} | |
temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow); | |
config._a[YEAR] = temp.year; | |
config._dayOfYear = temp.dayOfYear; | |
} | |
// convert an array to a date. | |
// the array should mirror the parameters below | |
// note: all values past the year are optional and will default to the lowest possible value. | |
// [year, month, day , hour, minute, second, millisecond] | |
function dateFromConfig(config) { | |
var i, date, input = [], currentDate, yearToUse; | |
if (config._d) { | |
return; | |
} | |
currentDate = currentDateArray(config); | |
//compute day of the year from weeks and weekdays | |
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { | |
dayOfYearFromWeekInfo(config); | |
} | |
//if the day of the year is set, figure out what it is | |
if (config._dayOfYear) { | |
yearToUse = dfl(config._a[YEAR], currentDate[YEAR]); | |
if (config._dayOfYear > daysInYear(yearToUse)) { | |
config._pf._overflowDayOfYear = true; | |
} | |
date = makeUTCDate(yearToUse, 0, config._dayOfYear); | |
config._a[MONTH] = date.getUTCMonth(); | |
config._a[DATE] = date.getUTCDate(); | |
} | |
// Default to current date. | |
// * if no year, month, day of month are given, default to today | |
// * if day of month is given, default month and year | |
// * if month is given, default only year | |
// * if year is given, don't default anything | |
for (i = 0; i < 3 && config._a[i] == null; ++i) { | |
config._a[i] = input[i] = currentDate[i]; | |
} | |
// Zero out whatever was not defaulted, including time | |
for (; i < 7; i++) { | |
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; | |
} | |
// Check for 24:00:00.000 | |
if (config._a[HOUR] === 24 && | |
config._a[MINUTE] === 0 && | |
config._a[SECOND] === 0 && | |
config._a[MILLISECOND] === 0) { | |
config._nextDay = true; | |
config._a[HOUR] = 0; | |
} | |
config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); | |
// Apply timezone offset from input. The actual zone can be changed | |
// with parseZone. | |
if (config._tzm != null) { | |
config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); | |
} | |
if (config._nextDay) { | |
config._a[HOUR] = 24; | |
} | |
} | |
function dateFromObject(config) { | |
var normalizedInput; | |
if (config._d) { | |
return; | |
} | |
normalizedInput = normalizeObjectUnits(config._i); | |
config._a = [ | |
normalizedInput.year, | |
normalizedInput.month, | |
normalizedInput.day || normalizedInput.date, | |
normalizedInput.hour, | |
normalizedInput.minute, | |
normalizedInput.second, | |
normalizedInput.millisecond | |
]; | |
dateFromConfig(config); | |
} | |
function currentDateArray(config) { | |
var now = new Date(); | |
if (config._useUTC) { | |
return [ | |
now.getUTCFullYear(), | |
now.getUTCMonth(), | |
now.getUTCDate() | |
]; | |
} else { | |
return [now.getFullYear(), now.getMonth(), now.getDate()]; | |
} | |
} | |
// date from string and format string | |
function makeDateFromStringAndFormat(config) { | |
if (config._f === moment.ISO_8601) { | |
parseISO(config); | |
return; | |
} | |
config._a = []; | |
config._pf.empty = true; | |
// This array is used to make a Date, either with `new Date` or `Date.UTC` | |
var string = '' + config._i, | |
i, parsedInput, tokens, token, skipped, | |
stringLength = string.length, | |
totalParsedInputLength = 0; | |
tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; | |
for (i = 0; i < tokens.length; i++) { | |
token = tokens[i]; | |
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; | |
if (parsedInput) { | |
skipped = string.substr(0, string.indexOf(parsedInput)); | |
if (skipped.length > 0) { | |
config._pf.unusedInput.push(skipped); | |
} | |
string = string.slice(string.indexOf(parsedInput) + parsedInput.length); | |
totalParsedInputLength += parsedInput.length; | |
} | |
// don't parse if it's not a known token | |
if (formatTokenFunctions[token]) { | |
if (parsedInput) { | |
config._pf.empty = false; | |
} | |
else { | |
config._pf.unusedTokens.push(token); | |
} | |
addTimeToArrayFromToken(token, parsedInput, config); | |
} | |
else if (config._strict && !parsedInput) { | |
config._pf.unusedTokens.push(token); | |
} | |
} | |
// add remaining unparsed input length to the string | |
config._pf.charsLeftOver = stringLength - totalParsedInputLength; | |
if (string.length > 0) { | |
config._pf.unusedInput.push(string); | |
} | |
// clear _12h flag if hour is <= 12 | |
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; | |
} | |
dateFromConfig(config); | |
checkOverflow(config); | |
} | |
function unescapeFormat(s) { | |
return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { | |
return p1 || p2 || p3 || p4; | |
}); | |
} | |
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript | |
function regexpEscape(s) { | |
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
} | |
// date from string and array of format strings | |
function makeDateFromStringAndArray(config) { | |
var tempConfig, | |
bestMoment, | |
scoreToBeat, | |
i, | |
currentScore; | |
if (config._f.length === 0) { | |
config._pf.invalidFormat = true; | |
config._d = new Date(NaN); | |
return; | |
} | |
for (i = 0; i < config._f.length; i++) { | |
currentScore = 0; | |
tempConfig = copyConfig({}, config); | |
if (config._useUTC != null) { | |
tempConfig._useUTC = config._useUTC; | |
} | |
tempConfig._pf = defaultParsingFlags(); | |
tempConfig._f = config._f[i]; | |
makeDateFromStringAndFormat(tempConfig); | |
if (!isValid(tempConfig)) { | |
continue; | |
} | |
// if there is any input that was not parsed add a penalty for that format | |
currentScore += tempConfig._pf.charsLeftOver; | |
//or tokens | |
currentScore += tempConfig._pf.unusedTokens.length * 10; | |
tempConfig._pf.score = currentScore; | |
if (scoreToBeat == null || currentScore < scoreToBeat) { | |
scoreToBeat = currentScore; | |
bestMoment = tempConfig; | |
} | |
} | |
extend(config, bestMoment || tempConfig); | |
} | |
// date from iso format | |
function parseISO(config) { | |
var i, l, | |
string = config._i, | |
match = isoRegex.exec(string); | |
if (match) { | |
config._pf.iso = true; | |
for (i = 0, l = isoDates.length; i < l; i++) { | |
if (isoDates[i][1].exec(string)) { | |
// match[5] should be 'T' or undefined | |
config._f = isoDates[i][0] + (match[6] || ' '); | |
break; | |
} | |
} | |
for (i = 0, l = isoTimes.length; i < l; i++) { | |
if (isoTimes[i][1].exec(string)) { | |
config._f += isoTimes[i][0]; | |
break; | |
} | |
} | |
if (string.match(parseTokenTimezone)) { | |
config._f += 'Z'; | |
} | |
makeDateFromStringAndFormat(config); | |
} else { | |
config._isValid = false; | |
} | |
} | |
// date from iso format or fallback | |
function makeDateFromString(config) { | |
parseISO(config); | |
if (config._isValid === false) { | |
delete config._isValid; | |
moment.createFromInputFallback(config); | |
} | |
} | |
function map(arr, fn) { | |
var res = [], i; | |
for (i = 0; i < arr.length; ++i) { | |
res.push(fn(arr[i], i)); | |
} | |
return res; | |
} | |
function makeDateFromInput(config) { | |
var input = config._i, matched; | |
if (input === undefined) { | |
config._d = new Date(); | |
} else if (isDate(input)) { | |
config._d = new Date(+input); | |
} else if ((matched = aspNetJsonRegex.exec(input)) !== null) { | |
config._d = new Date(+matched[1]); | |
} else if (typeof input === 'string') { | |
makeDateFromString(config); | |
} else if (isArray(input)) { | |
config._a = map(input.slice(0), function (obj) { | |
return parseInt(obj, 10); | |
}); | |
dateFromConfig(config); | |
} else if (typeof(input) === 'object') { | |
dateFromObject(config); | |
} else if (typeof(input) === 'number') { | |
// from milliseconds | |
config._d = new Date(input); | |
} else { | |
moment.createFromInputFallback(config); | |
} | |
} | |
function makeDate(y, m, d, h, M, s, ms) { | |
//can't just apply() to create a date: | |
//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply | |
var date = new Date(y, m, d, h, M, s, ms); | |
//the date constructor doesn't accept years < 1970 | |
if (y < 1970) { | |
date.setFullYear(y); | |
} | |
return date; | |
} | |
function makeUTCDate(y) { | |
var date = new Date(Date.UTC.apply(null, arguments)); | |
if (y < 1970) { | |
date.setUTCFullYear(y); | |
} | |
return date; | |
} | |
function parseWeekday(input, locale) { | |
if (typeof input === 'string') { | |
if (!isNaN(input)) { | |
input = parseInt(input, 10); | |
} | |
else { | |
input = locale.weekdaysParse(input); | |
if (typeof input !== 'number') { | |
return null; | |
} | |
} | |
} | |
return input; | |
} | |
/************************************ | |
Relative Time | |
************************************/ | |
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize | |
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { | |
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); | |
} | |
function relativeTime(posNegDuration, withoutSuffix, locale) { | |
var duration = moment.duration(posNegDuration).abs(), | |
seconds = round(duration.as('s')), | |
minutes = round(duration.as('m')), | |
hours = round(duration.as('h')), | |
days = round(duration.as('d')), | |
months = round(duration.as('M')), | |
years = round(duration.as('y')), | |
args = seconds < relativeTimeThresholds.s && ['s', seconds] || | |
minutes === 1 && ['m'] || | |
minutes < relativeTimeThresholds.m && ['mm', minutes] || | |
hours === 1 && ['h'] || | |
hours < relativeTimeThresholds.h && ['hh', hours] || | |
days === 1 && ['d'] || | |
days < relativeTimeThresholds.d && ['dd', days] || | |
months === 1 && ['M'] || | |
months < relativeTimeThresholds.M && ['MM', months] || | |
years === 1 && ['y'] || ['yy', years]; | |
args[2] = withoutSuffix; | |
args[3] = +posNegDuration > 0; | |
args[4] = locale; | |
return substituteTimeAgo.apply({}, args); | |
} | |
/************************************ | |
Week of Year | |
************************************/ | |
// firstDayOfWeek 0 = sun, 6 = sat | |
// the day of the week that starts the week | |
// (usually sunday or monday) | |
// firstDayOfWeekOfYear 0 = sun, 6 = sat | |
// the first week is the week that contains the first | |
// of this day of the week | |
// (eg. ISO weeks use thursday (4)) | |
function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { | |
var end = firstDayOfWeekOfYear - firstDayOfWeek, | |
daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(), | |
adjustedMoment; | |
if (daysToDayOfWeek > end) { | |
daysToDayOfWeek -= 7; | |
} | |
if (daysToDayOfWeek < end - 7) { | |
daysToDayOfWeek += 7; | |
} | |
adjustedMoment = moment(mom).add(daysToDayOfWeek, 'd'); | |
return { | |
week: Math.ceil(adjustedMoment.dayOfYear() / 7), | |
year: adjustedMoment.year() | |
}; | |
} | |
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday | |
function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { | |
var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; | |
d = d === 0 ? 7 : d; | |
weekday = weekday != null ? weekday : firstDayOfWeek; | |
daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); | |
dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; | |
return { | |
year: dayOfYear > 0 ? year : year - 1, | |
dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear | |
}; | |
} | |
/************************************ | |
Top Level Functions | |
************************************/ | |
function makeMoment(config) { | |
var input = config._i, | |
format = config._f, | |
res; | |
config._locale = config._locale || moment.localeData(config._l); | |
if (input === null || (format === undefined && input === '')) { | |
return moment.invalid({nullInput: true}); | |
} | |
if (typeof input === 'string') { | |
config._i = input = config._locale.preparse(input); | |
} | |
if (moment.isMoment(input)) { | |
return new Moment(input, true); | |
} else if (format) { | |
if (isArray(format)) { | |
makeDateFromStringAndArray(config); | |
} else { | |
makeDateFromStringAndFormat(config); | |
} | |
} else { | |
makeDateFromInput(config); | |
} | |
res = new Moment(config); | |
if (res._nextDay) { | |
// Adding is smart enough around DST | |
res.add(1, 'd'); | |
res._nextDay = undefined; | |
} | |
return res; | |
} | |
moment = function (input, format, locale, strict) { | |
var c; | |
if (typeof(locale) === 'boolean') { | |
strict = locale; | |
locale = undefined; | |
} | |
// object construction must be done this way. | |
// https://github.com/moment/moment/issues/1423 | |
c = {}; | |
c._isAMomentObject = true; | |
c._i = input; | |
c._f = format; | |
c._l = locale; | |
c._strict = strict; | |
c._isUTC = false; | |
c._pf = defaultParsingFlags(); | |
return makeMoment(c); | |
}; | |
moment.suppressDeprecationWarnings = false; | |
moment.createFromInputFallback = deprecate( | |
'moment construction falls back to js Date. This is ' + | |
'discouraged and will be removed in upcoming major ' + | |
'release. Please refer to ' + | |
'https://github.com/moment/moment/issues/1407 for more info.', | |
function (config) { | |
config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); | |
} | |
); | |
// Pick a moment m from moments so that m[fn](other) is true for all | |
// other. This relies on the function fn to be transitive. | |
// | |
// moments should either be an array of moment objects or an array, whose | |
// first element is an array of moment objects. | |
function pickBy(fn, moments) { | |
var res, i; | |
if (moments.length === 1 && isArray(moments[0])) { | |
moments = moments[0]; | |
} | |
if (!moments.length) { | |
return moment(); | |
} | |
res = moments[0]; | |
for (i = 1; i < moments.length; ++i) { | |
if (moments[i][fn](res)) { | |
res = moments[i]; | |
} | |
} | |
return res; | |
} | |
moment.min = function () { | |
var args = [].slice.call(arguments, 0); | |
return pickBy('isBefore', args); | |
}; | |
moment.max = function () { | |
var args = [].slice.call(arguments, 0); | |
return pickBy('isAfter', args); | |
}; | |
// creating with utc | |
moment.utc = function (input, format, locale, strict) { | |
var c; | |
if (typeof(locale) === 'boolean') { | |
strict = locale; | |
locale = undefined; | |
} | |
// object construction must be done this way. | |
// https://github.com/moment/moment/issues/1423 | |
c = {}; | |
c._isAMomentObject = true; | |
c._useUTC = true; | |
c._isUTC = true; | |
c._l = locale; | |
c._i = input; | |
c._f = format; | |
c._strict = strict; | |
c._pf = defaultParsingFlags(); | |
return makeMoment(c).utc(); | |
}; | |
// creating with unix timestamp (in seconds) | |
moment.unix = function (input) { | |
return moment(input * 1000); | |
}; | |
// duration | |
moment.duration = function (input, key) { | |
var duration = input, | |
// matching against regexp is expensive, do it on demand | |
match = null, | |
sign, | |
ret, | |
parseIso, | |
diffRes; | |
if (moment.isDuration(input)) { | |
duration = { | |
ms: input._milliseconds, | |
d: input._days, | |
M: input._months | |
}; | |
} else if (typeof input === 'number') { | |
duration = {}; | |
if (key) { | |
duration[key] = input; | |
} else { | |
duration.milliseconds = input; | |
} | |
} else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) { | |
sign = (match[1] === '-') ? -1 : 1; | |
duration = { | |
y: 0, | |
d: toInt(match[DATE]) * sign, | |
h: toInt(match[HOUR]) * sign, | |
m: toInt(match[MINUTE]) * sign, | |
s: toInt(match[SECOND]) * sign, | |
ms: toInt(match[MILLISECOND]) * sign | |
}; | |
} else if (!!(match = isoDurationRegex.exec(input))) { | |
sign = (match[1] === '-') ? -1 : 1; | |
parseIso = function (inp) { | |
// We'd normally use ~~inp for this, but unfortunately it also | |
// converts floats to ints. | |
// inp may be undefined, so careful calling replace on it. | |
var res = inp && parseFloat(inp.replace(',', '.')); | |
// apply sign while we're at it | |
return (isNaN(res) ? 0 : res) * sign; | |
}; | |
duration = { | |
y: parseIso(match[2]), | |
M: parseIso(match[3]), | |
d: parseIso(match[4]), | |
h: parseIso(match[5]), | |
m: parseIso(match[6]), | |
s: parseIso(match[7]), | |
w: parseIso(match[8]) | |
}; | |
} else if (typeof duration === 'object' && | |
('from' in duration || 'to' in duration)) { | |
diffRes = momentsDifference(moment(duration.from), moment(duration.to)); | |
duration = {}; | |
duration.ms = diffRes.milliseconds; | |
duration.M = diffRes.months; | |
} | |
ret = new Duration(duration); | |
if (moment.isDuration(input) && hasOwnProp(input, '_locale')) { | |
ret._locale = input._locale; | |
} | |
return ret; | |
}; | |
// version number | |
moment.version = VERSION; | |
// default format | |
moment.defaultFormat = isoFormat; | |
// constant that refers to the ISO standard | |
moment.ISO_8601 = function () {}; | |
// Plugins that add properties should also add the key here (null value), | |
// so we can properly clone ourselves. | |
moment.momentProperties = momentProperties; | |
// This function will be called whenever a moment is mutated. | |
// It is intended to keep the offset in sync with the timezone. | |
moment.updateOffset = function () {}; | |
// This function allows you to set a threshold for relative time strings | |
moment.relativeTimeThreshold = function (threshold, limit) { | |
if (relativeTimeThresholds[threshold] === undefined) { | |
return false; | |
} | |
if (limit === undefined) { | |
return relativeTimeThresholds[threshold]; | |
} | |
relativeTimeThresholds[threshold] = limit; | |
return true; | |
}; | |
moment.lang = deprecate( | |
'moment.lang is deprecated. Use moment.locale instead.', | |
function (key, value) { | |
return moment.locale(key, value); | |
} | |
); | |
// This function will load locale and then set the global locale. If | |
// no arguments are passed in, it will simply return the current global | |
// locale key. | |
moment.locale = function (key, values) { | |
var data; | |
if (key) { | |
if (typeof(values) !== 'undefined') { | |
data = moment.defineLocale(key, values); | |
} | |
else { | |
data = moment.localeData(key); | |
} | |
if (data) { | |
moment.duration._locale = moment._locale = data; | |
} | |
} | |
return moment._locale._abbr; | |
}; | |
moment.defineLocale = function (name, values) { | |
if (values !== null) { | |
values.abbr = name; | |
if (!locales[name]) { | |
locales[name] = new Locale(); | |
} | |
locales[name].set(values); | |
// backwards compat for now: also set the locale | |
moment.locale(name); | |
return locales[name]; | |
} else { | |
// useful for testing | |
delete locales[name]; | |
return null; | |
} | |
}; | |
moment.langData = deprecate( | |
'moment.langData is deprecated. Use moment.localeData instead.', | |
function (key) { | |
return moment.localeData(key); | |
} | |
); | |
// returns locale data | |
moment.localeData = function (key) { | |
var locale; | |
if (key && key._locale && key._locale._abbr) { | |
key = key._locale._abbr; | |
} | |
if (!key) { | |
return moment._locale; | |
} | |
if (!isArray(key)) { | |
//short-circuit everything else | |
locale = loadLocale(key); | |
if (locale) { | |
return locale; | |
} | |
key = [key]; | |
} | |
return chooseLocale(key); | |
}; | |
// compare moment object | |
moment.isMoment = function (obj) { | |
return obj instanceof Moment || | |
(obj != null && hasOwnProp(obj, '_isAMomentObject')); | |
}; | |
// for typechecking Duration objects | |
moment.isDuration = function (obj) { | |
return obj instanceof Duration; | |
}; | |
for (i = lists.length - 1; i >= 0; --i) { | |
makeList(lists[i]); | |
} | |
moment.normalizeUnits = function (units) { | |
return normalizeUnits(units); | |
}; | |
moment.invalid = function (flags) { | |
var m = moment.utc(NaN); | |
if (flags != null) { | |
extend(m._pf, flags); | |
} | |
else { | |
m._pf.userInvalidated = true; | |
} | |
return m; | |
}; | |
moment.parseZone = function () { | |
return moment.apply(null, arguments).parseZone(); | |
}; | |
moment.parseTwoDigitYear = function (input) { | |
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); | |
}; | |
/************************************ | |
Moment Prototype | |
************************************/ | |
extend(moment.fn = Moment.prototype, { | |
clone : function () { | |
return moment(this); | |
}, | |
valueOf : function () { | |
return +this._d + ((this._offset || 0) * 60000); | |
}, | |
unix : function () { | |
return Math.floor(+this / 1000); | |
}, | |
toString : function () { | |
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); | |
}, | |
toDate : function () { | |
return this._offset ? new Date(+this) : this._d; | |
}, | |
toISOString : function () { | |
var m = moment(this).utc(); | |
if (0 < m.year() && m.year() <= 9999) { | |
if ('function' === typeof Date.prototype.toISOString) { | |
// native implementation is ~50x faster, use it when we can | |
return this.toDate().toISOString(); | |
} else { | |
return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); | |
} | |
} else { | |
return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); | |
} | |
}, | |
toArray : function () { | |
var m = this; | |
return [ | |
m.year(), | |
m.month(), | |
m.date(), | |
m.hours(), | |
m.minutes(), | |
m.seconds(), | |
m.milliseconds() | |
]; | |
}, | |
isValid : function () { | |
return isValid(this); | |
}, | |
isDSTShifted : function () { | |
if (this._a) { | |
return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0; | |
} | |
return false; | |
}, | |
parsingFlags : function () { | |
return extend({}, this._pf); | |
}, | |
invalidAt: function () { | |
return this._pf.overflow; | |
}, | |
utc : function (keepLocalTime) { | |
return this.zone(0, keepLocalTime); | |
}, | |
local : function (keepLocalTime) { | |
if (this._isUTC) { | |
this.zone(0, keepLocalTime); | |
this._isUTC = false; | |
if (keepLocalTime) { | |
this.add(this._dateTzOffset(), 'm'); | |
} | |
} | |
return this; | |
}, | |
format : function (inputString) { | |
var output = formatMoment(this, inputString || moment.defaultFormat); | |
return this.localeData().postformat(output); | |
}, | |
add : createAdder(1, 'add'), | |
subtract : createAdder(-1, 'subtract'), | |
diff : function (input, units, asFloat) { | |
var that = makeAs(input, this), | |
zoneDiff = (this.zone() - that.zone()) * 6e4, | |
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') { | |
output = output / 12; | |
} | |
} else { | |
diff = (this - that); | |
output = units === 'second' ? diff / 1e3 : // 1000 | |
units === 'minute' ? diff / 6e4 : // 1000 * 60 | |
units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60 | |
units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst | |
units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst | |
diff; | |
} | |
return asFloat ? output : absRound(output); | |
}, | |
from : function (time, withoutSuffix) { | |
return moment.duration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix); | |
}, | |
fromNow : function (withoutSuffix) { | |
return this.from(moment(), withoutSuffix); | |
}, | |
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. | |
var now = time || moment(), | |
sod = makeAs(now, this).startOf('day'), | |
diff = this.diff(sod, 'days', true), | |
format = diff < -6 ? 'sameElse' : | |
diff < -1 ? 'lastWeek' : | |
diff < 0 ? 'lastDay' : | |
diff < 1 ? 'sameDay' : | |
diff < 2 ? 'nextDay' : | |
diff < 7 ? 'nextWeek' : 'sameElse'; | |
return this.format(this.localeData().calendar(format, this, moment(now))); | |
}, | |
isLeapYear : function () { | |
return isLeapYear(this.year()); | |
}, | |
isDST : function () { | |
return (this.zone() < this.clone().month(0).zone() || | |
this.zone() < this.clone().month(5).zone()); | |
}, | |
day : function (input) { | |
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); | |
if (input != null) { | |
input = parseWeekday(input, this.localeData()); | |
return this.add(input - day, 'd'); | |
} else { | |
return day; | |
} | |
}, | |
month : makeAccessor('Month', true), | |
startOf : function (units) { | |
units = normalizeUnits(units); | |
// the following switch intentionally omits break keywords | |
// to utilize falling through the cases. | |
switch (units) { | |
case 'year': | |
this.month(0); | |
/* falls through */ | |
case 'quarter': | |
case 'month': | |
this.date(1); | |
/* falls through */ | |
case 'week': | |
case 'isoWeek': | |
case 'day': | |
this.hours(0); | |
/* falls through */ | |
case 'hour': | |
this.minutes(0); | |
/* falls through */ | |
case 'minute': | |
this.seconds(0); | |
/* falls through */ | |
case 'second': | |
this.milliseconds(0); | |
/* falls through */ | |
} | |
// weeks are a special case | |
if (units === 'week') { | |
this.weekday(0); | |
} else if (units === 'isoWeek') { | |
this.isoWeekday(1); | |
} | |
// quarters are also special | |
if (units === 'quarter') { | |
this.month(Math.floor(this.month() / 3) * 3); | |
} | |
return this; | |
}, | |
endOf: function (units) { | |
units = normalizeUnits(units); | |
if (units === undefined || units === 'millisecond') { | |
return this; | |
} | |
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); | |
}, | |
isAfter: function (input, units) { | |
var inputMs; | |
units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond'); | |
if (units === 'millisecond') { | |
input = moment.isMoment(input) ? input : moment(input); | |
return +this > +input; | |
} else { | |
inputMs = moment.isMoment(input) ? +input : +moment(input); | |
return inputMs < +this.clone().startOf(units); | |
} | |
}, | |
isBefore: function (input, units) { | |
var inputMs; | |
units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond'); | |
if (units === 'millisecond') { | |
input = moment.isMoment(input) ? input : moment(input); | |
return +this < +input; | |
} else { | |
inputMs = moment.isMoment(input) ? +input : +moment(input); | |
return +this.clone().endOf(units) < inputMs; | |
} | |
}, | |
isSame: function (input, units) { | |
var inputMs; | |
units = normalizeUnits(units || 'millisecond'); | |
if (units === 'millisecond') { | |
input = moment.isMoment(input) ? input : moment(input); | |
return +this === +input; | |
} else { | |
inputMs = +moment(input); | |
return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units)); | |
} | |
}, | |
min: deprecate( | |
'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548', | |
function (other) { | |
other = moment.apply(null, arguments); | |
return other < this ? this : other; | |
} | |
), | |
max: deprecate( | |
'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548', | |
function (other) { | |
other = moment.apply(null, arguments); | |
return other > this ? this : other; | |
} | |
), | |
// 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 | |
// +0200, so we adjust the time as needed, to be valid. | |
// | |
// Keeping the time actually adds/subtracts (one hour) | |
// from the actual represented time. That is why we call updateOffset | |
// 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) { | |
var offset = this._offset || 0, | |
localAdjust; | |
if (input != null) { | |
if (typeof input === 'string') { | |
input = timezoneMinutesFromString(input); | |
} | |
if (Math.abs(input) < 16) { | |
input = input * 60; | |
} | |
if (!this._isUTC && keepLocalTime) { | |
localAdjust = this._dateTzOffset(); | |
} | |
this._offset = input; | |
this._isUTC = true; | |
if (localAdjust != null) { | |
this.subtract(localAdjust, 'm'); | |
} | |
if (offset !== input) { | |
if (!keepLocalTime || this._changeInProgress) { | |
addOrSubtractDurationFromMoment(this, | |
moment.duration(offset - input, 'm'), 1, false); | |
} else if (!this._changeInProgress) { | |
this._changeInProgress = true; | |
moment.updateOffset(this, true); | |
this._changeInProgress = null; | |
} | |
} | |
} else { | |
return this._isUTC ? offset : this._dateTzOffset(); | |
} | |
return this; | |
}, | |
zoneAbbr : function () { | |
return this._isUTC ? 'UTC' : ''; | |
}, | |
zoneName : function () { | |
return this._isUTC ? 'Coordinated Universal Time' : ''; | |
}, | |
parseZone : function () { | |
if (this._tzm) { | |
this.zone(this._tzm); | |
} else if (typeof this._i === 'string') { | |
this.zone(this._i); | |
} | |
return this; | |
}, | |
hasAlignedHourOffset : function (input) { | |
if (!input) { | |
input = 0; | |
} | |
else { | |
input = moment(input).zone(); | |
} | |
return (this.zone() - input) % 60 === 0; | |
}, | |
daysInMonth : function () { | |
return daysInMonth(this.year(), this.month()); | |
}, | |
dayOfYear : function (input) { | |
var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1; | |
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); | |
}, | |
quarter : function (input) { | |
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); | |
}, | |
weekYear : function (input) { | |
var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year; | |
return input == null ? year : this.add((input - year), 'y'); | |
}, | |
isoWeekYear : function (input) { | |
var year = weekOfYear(this, 1, 4).year; | |
return input == null ? year : this.add((input - year), 'y'); | |
}, | |
week : function (input) { | |
var week = this.localeData().week(this); | |
return input == null ? week : this.add((input - week) * 7, 'd'); | |
}, | |
isoWeek : function (input) { | |
var week = weekOfYear(this, 1, 4).week; | |
return input == null ? week : this.add((input - week) * 7, 'd'); | |
}, | |
weekday : function (input) { | |
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; | |
return input == null ? weekday : this.add(input - weekday, 'd'); | |
}, | |
isoWeekday : function (input) { | |
// behaves the same as moment#day except | |
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) | |
// as a setter, sunday should belong to the previous week. | |
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); | |
}, | |
isoWeeksInYear : function () { | |
return weeksInYear(this.year(), 1, 4); | |
}, | |
weeksInYear : function () { | |
var weekInfo = this.localeData()._week; | |
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); | |
}, | |
get : function (units) { | |
units = normalizeUnits(units); | |
return this[units](); | |
}, | |
set : function (units, value) { | |
units = normalizeUnits(units); | |
if (typeof this[units] === 'function') { | |
this[units](value); | |
} | |
return this; | |
}, | |
// If passed a locale key, it will set the locale for this | |
// instance. Otherwise, it will return the locale configuration | |
// variables for this instance. | |
locale : function (key) { | |
var newLocaleData; | |
if (key === undefined) { | |
return this._locale._abbr; | |
} else { | |
newLocaleData = moment.localeData(key); | |
if (newLocaleData != null) { | |
this._locale = newLocaleData; | |
} | |
return this; | |
} | |
}, | |
lang : deprecate( | |
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', | |
function (key) { | |
if (key === undefined) { | |
return this.localeData(); | |
} else { | |
return this.locale(key); | |
} | |
} | |
), | |
localeData : function () { | |
return this._locale; | |
}, | |
_dateTzOffset : 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; | |
} | |
}); | |
function rawMonthSetter(mom, value) { | |
var dayOfMonth; | |
// TODO: Move this out of here! | |
if (typeof value === 'string') { | |
value = mom.localeData().monthsParse(value); | |
// TODO: Another silent failure? | |
if (typeof value !== 'number') { | |
return mom; | |
} | |
} | |
dayOfMonth = Math.min(mom.date(), | |
daysInMonth(mom.year(), value)); | |
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); | |
return mom; | |
} | |
function rawGetter(mom, unit) { | |
return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit](); | |
} | |
function rawSetter(mom, unit, value) { | |
if (unit === 'Month') { | |
return rawMonthSetter(mom, value); | |
} else { | |
return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); | |
} | |
} | |
function makeAccessor(unit, keepTime) { | |
return function (value) { | |
if (value != null) { | |
rawSetter(this, unit, value); | |
moment.updateOffset(this, keepTime); | |
return this; | |
} else { | |
return rawGetter(this, unit); | |
} | |
}; | |
} | |
moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false); | |
moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false); | |
moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false); | |
// Setting the hour should keep the time, because the user explicitly | |
// specified which hour he wants. So trying to maintain the same hour (in | |
// a new timezone) makes sense. Adding/subtracting hours does not follow | |
// this rule. | |
moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true); | |
// moment.fn.month is defined separately | |
moment.fn.date = makeAccessor('Date', true); | |
moment.fn.dates = deprecate('dates accessor is deprecated. Use date instead.', makeAccessor('Date', true)); | |
moment.fn.year = makeAccessor('FullYear', true); | |
moment.fn.years = deprecate('years accessor is deprecated. Use year instead.', makeAccessor('FullYear', true)); | |
// add plural methods | |
moment.fn.days = moment.fn.day; | |
moment.fn.months = moment.fn.month; | |
moment.fn.weeks = moment.fn.week; | |
moment.fn.isoWeeks = moment.fn.isoWeek; | |
moment.fn.quarters = moment.fn.quarter; | |
// add aliased format methods | |
moment.fn.toJSON = moment.fn.toISOString; | |
/************************************ | |
Duration Prototype | |
************************************/ | |
function daysToYears (days) { | |
// 400 years have 146097 days (taking into account leap year rules) | |
return days * 400 / 146097; | |
} | |
function yearsToDays (years) { | |
// years * 365 + absRound(years / 4) - | |
// absRound(years / 100) + absRound(years / 400); | |
return years * 146097 / 400; | |
} | |
extend(moment.duration.fn = Duration.prototype, { | |
_bubble : function () { | |
var milliseconds = this._milliseconds, | |
days = this._days, | |
months = this._months, | |
data = this._data, | |
seconds, minutes, hours, years = 0; | |
// The following code bubbles up values, see the tests for | |
// examples of what that means. | |
data.milliseconds = milliseconds % 1000; | |
seconds = absRound(milliseconds / 1000); | |
data.seconds = seconds % 60; | |
minutes = absRound(seconds / 60); | |
data.minutes = minutes % 60; | |
hours = absRound(minutes / 60); | |
data.hours = hours % 24; | |
days += absRound(hours / 24); | |
// Accurately convert days to years, assume start from year 0. | |
years = absRound(daysToYears(days)); | |
days -= absRound(yearsToDays(years)); | |
// 30 days to a month | |
// TODO (iskren): Use anchor date (like 1st Jan) to compute this. | |
months += absRound(days / 30); | |
days %= 30; | |
// 12 months -> 1 year | |
years += absRound(months / 12); | |
months %= 12; | |
data.days = days; | |
data.months = months; | |
data.years = years; | |
}, | |
abs : function () { | |
this._milliseconds = Math.abs(this._milliseconds); | |
this._days = Math.abs(this._days); | |
this._months = Math.abs(this._months); | |
this._data.milliseconds = Math.abs(this._data.milliseconds); | |
this._data.seconds = Math.abs(this._data.seconds); | |
this._data.minutes = Math.abs(this._data.minutes); | |
this._data.hours = Math.abs(this._data.hours); | |
this._data.months = Math.abs(this._data.months); | |
this._data.years = Math.abs(this._data.years); | |
return this; | |
}, | |
weeks : function () { | |
return absRound(this.days() / 7); | |
}, | |
valueOf : function () { | |
return this._milliseconds + | |
this._days * 864e5 + | |
(this._months % 12) * 2592e6 + | |
toInt(this._months / 12) * 31536e6; | |
}, | |
humanize : function (withSuffix) { | |
var output = relativeTime(this, !withSuffix, this.localeData()); | |
if (withSuffix) { | |
output = this.localeData().pastFuture(+this, output); | |
} | |
return this.localeData().postformat(output); | |
}, | |
add : function (input, val) { | |
// supports only 2.0-style add(1, 's') or add(moment) | |
var dur = moment.duration(input, val); | |
this._milliseconds += dur._milliseconds; | |
this._days += dur._days; | |
this._months += dur._months; | |
this._bubble(); | |
return this; | |
}, | |
subtract : function (input, val) { | |
var dur = moment.duration(input, val); | |
this._milliseconds -= dur._milliseconds; | |
this._days -= dur._days; | |
this._months -= dur._months; | |
this._bubble(); | |
return this; | |
}, | |
get : function (units) { | |
units = normalizeUnits(units); | |
return this[units.toLowerCase() + 's'](); | |
}, | |
as : function (units) { | |
var days, months; | |
units = normalizeUnits(units); | |
if (units === 'month' || units === 'year') { | |
days = this._days + this._milliseconds / 864e5; | |
months = this._months + daysToYears(days) * 12; | |
return units === 'month' ? months : months / 12; | |
} else { | |
// handle milliseconds separately because of floating point math errors (issue #1867) | |
days = this._days + Math.round(yearsToDays(this._months / 12)); | |
switch (units) { | |
case 'week': return days / 7 + this._milliseconds / 6048e5; | |
case 'day': return days + this._milliseconds / 864e5; | |
case 'hour': return days * 24 + this._milliseconds / 36e5; | |
case 'minute': return days * 24 * 60 + this._milliseconds / 6e4; | |
case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000; | |
// Math.floor prevents floating point math errors here | |
case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds; | |
default: throw new Error('Unknown unit ' + units); | |
} | |
} | |
}, | |
lang : moment.fn.lang, | |
locale : moment.fn.locale, | |
toIsoString : deprecate( | |
'toIsoString() is deprecated. Please use toISOString() instead ' + | |
'(notice the capitals)', | |
function () { | |
return this.toISOString(); | |
} | |
), | |
toISOString : function () { | |
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js | |
var years = Math.abs(this.years()), | |
months = Math.abs(this.months()), | |
days = Math.abs(this.days()), | |
hours = Math.abs(this.hours()), | |
minutes = Math.abs(this.minutes()), | |
seconds = Math.abs(this.seconds() + this.milliseconds() / 1000); | |
if (!this.asSeconds()) { | |
// this is the same as C#'s (Noda) and python (isodate)... | |
// but not other JS (goog.date) | |
return 'P0D'; | |
} | |
return (this.asSeconds() < 0 ? '-' : '') + | |
'P' + | |
(years ? years + 'Y' : '') + | |
(months ? months + 'M' : '') + | |
(days ? days + 'D' : '') + | |
((hours || minutes || seconds) ? 'T' : '') + | |
(hours ? hours + 'H' : '') + | |
(minutes ? minutes + 'M' : '') + | |
(seconds ? seconds + 'S' : ''); | |
}, | |
localeData : function () { | |
return this._locale; | |
} | |
}); | |
moment.duration.fn.toString = moment.duration.fn.toISOString; | |
function makeDurationGetter(name) { | |
moment.duration.fn[name] = function () { | |
return this._data[name]; | |
}; | |
} | |
for (i in unitMillisecondFactors) { | |
if (hasOwnProp(unitMillisecondFactors, i)) { | |
makeDurationGetter(i.toLowerCase()); | |
} | |
} | |
moment.duration.fn.asMilliseconds = function () { | |
return this.as('ms'); | |
}; | |
moment.duration.fn.asSeconds = function () { | |
return this.as('s'); | |
}; | |
moment.duration.fn.asMinutes = function () { | |
return this.as('m'); | |
}; | |
moment.duration.fn.asHours = function () { | |
return this.as('h'); | |
}; | |
moment.duration.fn.asDays = function () { | |
return this.as('d'); | |
}; | |
moment.duration.fn.asWeeks = function () { | |
return this.as('weeks'); | |
}; | |
moment.duration.fn.asMonths = function () { | |
return this.as('M'); | |
}; | |
moment.duration.fn.asYears = function () { | |
return this.as('y'); | |
}; | |
/************************************ | |
Default Locale | |
************************************/ | |
// Set default locale, other locale will inherit from English. | |
moment.locale('en', { | |
ordinalParse: /\d{1,2}(th|st|nd|rd)/, | |
ordinal : function (number) { | |
var b = number % 10, | |
output = (toInt(number % 100 / 10) === 1) ? 'th' : | |
(b === 1) ? 'st' : | |
(b === 2) ? 'nd' : | |
(b === 3) ? 'rd' : 'th'; | |
return number + output; | |
} | |
}); | |
/* EMBED_LOCALES */ | |
/************************************ | |
Exposing Moment | |
************************************/ | |
function makeGlobal(shouldDeprecate) { | |
/*global ender:false */ | |
if (typeof ender !== 'undefined') { | |
return; | |
} | |
oldGlobalMoment = globalScope.moment; | |
if (shouldDeprecate) { | |
globalScope.moment = deprecate( | |
'Accessing Moment through the global scope is ' + | |
'deprecated, and will be removed in an upcoming ' + | |
'release.', | |
moment); | |
} else { | |
globalScope.moment = moment; | |
} | |
} | |
// CommonJS module is defined | |
if (hasModule) { | |
module.exports = moment; | |
} else if (typeof define === 'function' && define.amd) { | |
define('moment', function (require, exports, module) { | |
if (module.config && module.config() && module.config().noGlobal === true) { | |
// release the global variable | |
globalScope.moment = oldGlobalMoment; | |
} | |
return moment; | |
}); | |
makeGlobal(true); | |
} else { | |
makeGlobal(); | |
} | |
}).call(this); | |
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | |
},{}],2:[function(require,module,exports){ | |
var options = exports.options = require('./options'); | |
exports.Parser = require('./parsers/parser').Parser; | |
exports.Refiner = require('./refiners/refiner').Filter; | |
exports.Filter = require('./refiners/refiner').Filter; | |
exports.ParsedResult = require('./result').ParsedResult; | |
exports.ParsedComponents = require('./result').ParsedComponents; | |
var Chrono = function(option) { | |
option = option || exports.options.strictOption(); | |
this.option = option; | |
this.parsers = new Object(option.parsers); | |
this.refiners = new Object(option.refiners); | |
} | |
Chrono.prototype.parse = function(text, refDate, opt) { | |
refDate = refDate || new Date(); | |
opt = opt || {}; | |
var allResults = []; | |
this.parsers.forEach(function (parser) { | |
var results = parser.execute(text, refDate, opt); | |
allResults = allResults.concat(results); | |
}); | |
allResults.sort(function(a, b) { | |
return a.index - b.index; | |
}); | |
this.refiners.forEach(function (refiner) { | |
allResults = refiner.refine(text, allResults, opt); | |
}); | |
return allResults; | |
}; | |
Chrono.prototype.parseDate = function(text, refDate, opt) { | |
var results = this.parse(text, refDate, opt); | |
if (results.length > 0) { | |
return results[0].start.date(); | |
} | |
return null; | |
} | |
exports.Chrono = Chrono; | |
exports.strict = new Chrono( options.strictOption() ); | |
exports.casual = new Chrono( options.casualOption() ); | |
exports.parse = function () { | |
return exports.casual.parse.apply(exports.casual, arguments); | |
} | |
exports.parseDate = function () { | |
return exports.casual.parseDate.apply(exports.casual, arguments); | |
} | |
},{"./options":3,"./parsers/parser":15,"./refiners/refiner":23,"./result":24}],3:[function(require,module,exports){ | |
var ENISOFormatParser = require('./parsers/EN/ENISOFormatParser').Parser; | |
var ENDeadlineFormatParser = require('./parsers/EN/ENDeadlineFormatParser').Parser; | |
var ENMonthNameLittleEndianParser = require('./parsers/EN/ENMonthNameLittleEndianParser').Parser; | |
var ENMonthNameMiddleEndianParser = require('./parsers/EN/ENMonthNameMiddleEndianParser').Parser; | |
var ENSlashDateFormatParser = require('./parsers/EN/ENSlashDateFormatParser').Parser; | |
var ENTimeAgoFormatParser = require('./parsers/EN/ENTimeAgoFormatParser').Parser; | |
var ENTimeExpessionParser = require('./parsers/EN/ENTimeExpressionParser').Parser; | |
var ENWeekdayParser = require('./parsers/EN/ENWeekdayParser').Parser; | |
var ENCasualDateParser = require('./parsers/EN/ENCasualDateParser').Parser; | |
var ENMergeDateTimeRefiner = require('./refiners/EN/ENMergeDateTimeRefiner').Refiner; | |
var ENMergeDateRangeRefiner = require('./refiners/EN/ENMergeDateRangeRefiner').Refiner; | |
var JPStandardParser = require('./parsers/JP/JPStandardParser').Parser; | |
var JPCasualDateParser = require('./parsers/JP/JPCasualDateParser').Parser; | |
var JPMergeDateRangeRefiner = require('./refiners/JP/JPMergeDateRangeRefiner').Refiner; | |
var OverlapRemovalRefiner = require('./refiners/OverlapRemovalRefiner').Refiner; | |
var ExtractTimezoneOffsetRefiner = require('./refiners/ExtractTimezoneOffsetRefiner').Refiner; | |
var ExtractTimezoneAbbrRefiner = require('./refiners/ExtractTimezoneAbbrRefiner').Refiner; | |
var UnlikelyFormatFilter = require('./refiners/UnlikelyFormatFilter').Refiner; | |
exports.strictOption = function () { | |
return { | |
parsers: [ | |
// EN | |
new ENISOFormatParser(), | |
new ENDeadlineFormatParser(), | |
new ENMonthNameLittleEndianParser(), | |
new ENMonthNameMiddleEndianParser(), | |
new ENSlashDateFormatParser(), | |
new ENTimeAgoFormatParser(), | |
new ENTimeExpessionParser(), | |
// JP | |
new JPStandardParser(), | |
], | |
refiners: [ | |
// Removing overlaping first | |
new OverlapRemovalRefiner(), | |
// ETC | |
new ENMergeDateTimeRefiner(), | |
new ENMergeDateRangeRefiner(), | |
new JPMergeDateRangeRefiner(), | |
// Extract additional info later | |
new ExtractTimezoneOffsetRefiner(), | |
new ExtractTimezoneAbbrRefiner(), | |
new UnlikelyFormatFilter() | |
] | |
} | |
}; | |
exports.casualOption = function () { | |
var options = exports.strictOption(); | |
// EN | |
options.parsers.unshift(new ENCasualDateParser()); | |
options.parsers.unshift(new ENWeekdayParser()); | |
// JP | |
options.parsers.unshift(new JPCasualDateParser()); | |
return options; | |
}; | |
},{"./parsers/EN/ENCasualDateParser":4,"./parsers/EN/ENDeadlineFormatParser":5,"./parsers/EN/ENISOFormatParser":6,"./parsers/EN/ENMonthNameLittleEndianParser":7,"./parsers/EN/ENMonthNameMiddleEndianParser":8,"./parsers/EN/ENSlashDateFormatParser":9,"./parsers/EN/ENTimeAgoFormatParser":10,"./parsers/EN/ENTimeExpressionParser":11,"./parsers/EN/ENWeekdayParser":12,"./parsers/JP/JPCasualDateParser":13,"./parsers/JP/JPStandardParser":14,"./refiners/EN/ENMergeDateRangeRefiner":16,"./refiners/EN/ENMergeDateTimeRefiner":17,"./refiners/ExtractTimezoneAbbrRefiner":18,"./refiners/ExtractTimezoneOffsetRefiner":19,"./refiners/JP/JPMergeDateRangeRefiner":20,"./refiners/OverlapRemovalRefiner":21,"./refiners/UnlikelyFormatFilter":22}],4:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /(today|tonight|tomorrow|tmr|yesterday|last\s*night|this\s*(morning|afternoon|evening))(?=\W|$)/i; | |
exports.Parser = function ENCasualDateParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var index = match.index; | |
var text = match[0]; | |
var result = new ParsedResult({ | |
index: index, | |
text: text, | |
ref: ref, | |
}); | |
var refMoment = moment(ref); | |
var startMoment = refMoment.clone(); | |
var lowerText = text.toLowerCase(); | |
if(lowerText == 'tonight'){ | |
// Normally means this coming midnight | |
result.start.imply('hour', 22); | |
result.start.imply('meridiem', 1); | |
} else if(lowerText == 'tomorrow' || lowerText == 'tmr'){ | |
// Check not "Tomorrow" on late night | |
if(refMoment.hour() > 4) { | |
startMoment.add(1, 'day'); | |
} | |
} else if(lowerText == 'yesterday') { | |
startMoment.add(-1, 'day'); | |
} | |
else if(lowerText.match(/last\s*night/)) { | |
result.start.imply('hour', 0); | |
if (refMoment.hour() > 6) { | |
startMoment.add(-1, 'day'); | |
} | |
} else if (lowerText.match("this")) { | |
var secondMatch = match[2].toLowerCase(); | |
if (secondMatch == "afternoon") { | |
result.start.imply('hour', 15); | |
} else if (secondMatch == "evening") { | |
result.start.imply('hour', 18); | |
} else if (secondMatch == "morning") { | |
result.start.imply('hour', 6); | |
} | |
} | |
result.start.assign('day', startMoment.date()) | |
result.start.assign('month', startMoment.month() + 1) | |
result.start.assign('year', startMoment.year()) | |
result.tags['ENCasualDateParser'] = true; | |
return result; | |
} | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],5:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /(\W|^)(within|in)\s*([0-9]+)\s*(minutes?|hours?|days?)\s*(?=(?:\W|$))/i; | |
exports.Parser = function ENDeadlineFormatParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var index = match.index + match[1].length; | |
var text = match[0]; | |
text = match[0].substr(match[1].length, match[0].length - match[1].length); | |
var result = new ParsedResult({ | |
index: index, | |
text: text, | |
ref: ref, | |
}); | |
var num = match[3]; | |
num = parseInt(num); | |
var date = moment(ref); | |
if (match[4].match(/day/)) { | |
date.add(num, 'd'); | |
result.start.assign('year', date.year()); | |
result.start.assign('month', date.month() + 1); | |
result.start.assign('day', date.date()); | |
return result; | |
} | |
if (match[4].match(/hour/)) { | |
date.add(num, 'hour'); | |
} else if (match[4].match(/minute/)) { | |
date.add(num, 'minute'); | |
} | |
result.start.imply('year', date.year()); | |
result.start.imply('month', date.month() + 1); | |
result.start.imply('day', date.date()); | |
result.start.assign('hour', date.hour()); | |
result.start.assign('minute', date.minute()); | |
result.tags['ENDeadlineFormatParser'] = true; | |
return result; | |
}; | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],6:[function(require,module,exports){ | |
/* | |
ISO 8601 | |
http://www.w3.org/TR/NOTE-datetime | |
// YYYY-MM-DD | |
// YYYY-MM-DDThh:mmTZD | |
// YYYY-MM-DDThh:mm:ssTZD | |
// YYYY-MM-DDThh:mm:ss.sTZD | |
// TZD = (Z or +hh:mm or -hh:mm) | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = new RegExp('(\\W|^)' | |
+ '([0-9]{4})\\-([0-9]{1,2})\\-([0-9]{1,2})' | |
+ '(?:T' //.. | |
+ '([0-9]{1,2}):([0-9]{1,2})' // hh:mm | |
+ '(?::([0-9]{1,2})(?:\\.\\d{1,4})?)?' // :ss.s | |
+ '(?:Z|([+-]\\d{2}):?(\\d{2})?)' // TZD (Z or ±hh:mm or ±hhmm or ±hh) | |
+ ')?' //.. | |
+ '(?=\\W|$)', 'i'); | |
var YEAR_NUMBER_GROUP = 2; | |
var MONTH_NUMBER_GROUP = 3; | |
var DATE_NUMBER_GROUP = 4; | |
var HOUR_NUMBER_GROUP = 5; | |
var MINUTE_NUMBER_GROUP = 6; | |
var SECOND_NUMBER_GROUP = 7; | |
var TZD_HOUR_OFFSET_GROUP = 8; | |
var TZD_MINUTE_OFFSET_GROUP = 9; | |
exports.Parser = function ENISOFormatParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var text = match[0].substr(match[1]); | |
var index = match.index + match[1].length; | |
var result = new ParsedResult({ | |
text: text, | |
index: index, | |
ref: ref, | |
}) | |
result.start.assign('year', parseInt(match[YEAR_NUMBER_GROUP])); | |
result.start.assign('month', parseInt(match[MONTH_NUMBER_GROUP])); | |
result.start.assign('day', parseInt(match[DATE_NUMBER_GROUP])); | |
if (moment(result.start.get('month')) > 12 || moment(result.start.get('month')) < 1 || | |
moment(result.start.get('day')) > 31 || moment(result.start.get('day')) < 1) { | |
return null; | |
} | |
if (match[HOUR_NUMBER_GROUP] != null) { | |
result.start.assign('hour', | |
parseInt(match[HOUR_NUMBER_GROUP])); | |
result.start.assign('minute', | |
parseInt(match[MINUTE_NUMBER_GROUP])); | |
if (match[SECOND_NUMBER_GROUP] != null) { | |
result.start.assign('second', | |
parseInt(match[SECOND_NUMBER_GROUP])); | |
} | |
if (match[TZD_HOUR_OFFSET_GROUP] == null) { | |
result.start.assign('timezoneOffset', 0); | |
} else { | |
var minuteOffset = 0; | |
var hourOffset = parseInt(match[TZD_HOUR_OFFSET_GROUP]); | |
if (match[TZD_MINUTE_OFFSET_GROUP] != null) | |
minuteOffset = parseInt(match[TZD_MINUTE_OFFSET_GROUP]); | |
var offset = hourOffset * 60; | |
if (offset < 0) { | |
offset -= minuteOffset; | |
} else { | |
offset += minuteOffset; | |
} | |
result.start.assign('timezoneOffset', offset); | |
} | |
} | |
result.tags['ENISOFormatParser'] = true; | |
return result; | |
}; | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],7:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var util = require('../../utils/EN'); | |
var DAYS_OFFSET = { 'sunday': 0, 'sun': 0, 'monday': 1, 'mon': 1,'tuesday': 2, 'tue':2, 'wednesday': 3, 'wed': 3, | |
'thursday': 4, 'thur': 4, 'thu': 4,'friday': 5, 'fri': 5,'saturday': 6, 'sat': 6,} | |
var PATTERN = new RegExp('(\\W|^)' + | |
'(?:(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sun|Mon|Tue|Wed|Thu|Fri|Sat)\\s*,?\\s*)?' + | |
'([0-9]{1,2})(?:st|nd|rd|th)?' + | |
'(?:\\s*(?:to|\\-|\\s)\\s*([0-9]{1,2})(?:st|nd|rd|th)?)?\\s*(?:of)?\\s*' + | |
'(Jan(?:uary|\\.)?|Feb(?:ruary|\\.)?|Mar(?:ch|\\.)?|Apr(?:il|\\.)?|May|Jun(?:e|\\.)?|Jul(?:y|\\.)?|Aug(?:ust|\\.)?|Sep(?:tember|\\.)?|Oct(?:ober|\\.)?|Nov(?:ember|\\.)?|Dec(?:ember|\\.)?)' + | |
'(?:(\\s*[0-9]{2,4}(?![^\\s]\\d))(\\s*BE)?)?' + | |
'(?=\\W|$)', 'i' | |
); | |
var WEEKDAY_GROUP = 2; | |
var DATE_GROUP = 3; | |
var DATE_TO_GROUP = 4; | |
var MONTH_NAME_GROUP = 5; | |
var YEAR_GROUP = 6; | |
var YEAR_BE_GROUP = 7; | |
exports.Parser = function ENMonthNameLittleEndianParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var result = new ParsedResult({ | |
text: match[0].substr(match[1].length, match[0].length - match[1].length), | |
index: match.index + match[1].length, | |
ref: ref, | |
}); | |
var startMoment = moment(ref); | |
var month = match[MONTH_NAME_GROUP]; | |
month = util.MONTH_OFFSET[month.toLowerCase()]; | |
var day = match[DATE_GROUP]; | |
day = parseInt(day); | |
var year = null; | |
if (match[YEAR_GROUP]) { | |
year = match[YEAR_GROUP]; | |
year = parseInt(year); | |
if(match[YEAR_BE_GROUP]){ | |
//BC | |
year = year - 543; | |
} else if (year < 100){ | |
year = year + 2000; | |
} | |
} | |
startMoment.month(month - 1); | |
startMoment.date(day); | |
if(year){ | |
startMoment.year(year); | |
result.start.assign('day', startMoment.date()); | |
result.start.assign('month', startMoment.month() + 1); | |
result.start.assign('year', startMoment.year()); | |
} else { | |
//Find the most appropriated year | |
startMoment.year(moment(ref).year()); | |
var nextYear = startMoment.clone().add(1, 'y'); | |
var lastYear = startMoment.clone().add(-1, 'y'); | |
if( Math.abs(nextYear.diff(moment(ref))) < Math.abs(startMoment.diff(moment(ref))) ){ | |
startMoment = nextYear; | |
} | |
else if( Math.abs(lastYear.diff(moment(ref))) < Math.abs(startMoment.diff(moment(ref))) ){ | |
startMoment = lastYear; | |
} | |
result.start.assign('day', startMoment.date()); | |
result.start.assign('month', startMoment.month() + 1); | |
result.start.imply('year', startMoment.year()); | |
} | |
// Weekday component | |
if (match[WEEKDAY_GROUP]) { | |
var weekday = match[WEEKDAY_GROUP]; | |
weekday = util.WEEKDAY_OFFSET[weekday.toLowerCase()] | |
result.start.assign('weekday', weekday); | |
} | |
// Text can be 'range' value. Such as '12 - 13 January 2012' | |
if (match[DATE_TO_GROUP]) { | |
result.end = result.start.clone(); | |
result.end.assign('day', parseInt(match[DATE_TO_GROUP])); | |
} | |
result.tags['ENMonthNameLittleEndianParser'] = true; | |
return result; | |
}; | |
} | |
},{"../../result":24,"../../utils/EN":25,"../parser":15,"moment":1}],8:[function(require,module,exports){ | |
/* | |
The parser for parsing US's date format that begin with month's name. | |
EX. | |
- January 13 | |
- January 13, 2012 | |
- January 13 - 15, 2012 | |
- Tuesday, January 13, 2012 | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var DAYS_OFFSET = { 'sunday': 0, 'sun': 0, 'monday': 1, 'mon': 1,'tuesday': 2, 'tue':2, 'wednesday': 3, 'wed': 3, | |
'thursday': 4, 'thur': 4, 'thu': 4,'friday': 5, 'fri': 5,'saturday': 6, 'sat': 6,} | |
var regFullPattern = /(\W|^)((Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s*,?\s*)?(Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|November|Dec|December)\s*(([0-9]{1,2})(st|nd|rd|th)?\s*(to|\-)\s*)?([0-9]{1,2})(st|nd|rd|th)?(,)?(\s*[0-9]{4})(\s*BE)?(\W|$)/i; | |
var regShortPattern = /(\W|^)((Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s*,?\s*)?(Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|November|Dec|December)\s*(([0-9]{1,2})(st|nd|rd|th)?\s*(to|\-)\s*)?([0-9]{1,2})(st|nd|rd|th)?([^0-9]|$)/i; | |
exports.Parser = function ENMonthNameMiddleEndianParser(){ | |
Parser.call(this); | |
this.pattern = function() { return regShortPattern; } | |
this.extract = function(text, ref, match, opt){ | |
var result = new ParsedResult(); | |
var impliedComponents = []; | |
var date = null; | |
var originalText = ''; | |
var index = match.index; | |
text = text.substr(index); | |
var match = text.match(regFullPattern); | |
if(match && text.indexOf(match[0]) == 0){ | |
var text = match[0]; | |
text = text.substring(match[1].length, match[0].length - match[14].length); | |
index = index + match[1].length; | |
originalText = text; | |
text = text.replace(match[2], ''); | |
text = text.replace(match[4], match[4]+' '); | |
if(match[5]) text = text.replace(match[5],''); | |
if(match[10]) text = text.replace(match[10],''); | |
if(match[11]) text = text.replace(',',' '); | |
if(match[13]){ | |
var years = match[12]; | |
years = ' ' + (parseInt(years) - 543); | |
text = text.replace(match[13], ''); | |
text = text.replace(match[12], years); | |
} | |
text = text.replace(match[9],parseInt(match[9])+''); | |
date = moment(text,'MMMM DD YYYY'); | |
if(!date) return null; | |
result.start.assign('day', date.date()); | |
result.start.assign('month', date.month() + 1); | |
result.start.assign('year', date.year()); | |
} else { | |
match = text.match(regShortPattern); | |
if(!match) return null; | |
//Short Pattern (without years) | |
var text = match[0]; | |
text = text.substring(match[1].length, match[0].length - match[11].length); | |
index = index + match[1].length; | |
originalText = text; | |
text = text.replace(match[2], ''); | |
text = text.replace(match[4], match[4]+' '); | |
if(match[4]) text = text.replace(match[5],''); | |
date = moment(text,'MMMM DD'); | |
if(!date) return null; | |
//Find the most appropriated year | |
impliedComponents.push('year') | |
date.year(moment(ref).year()); | |
var nextYear = date.clone().add(1, 'year'); | |
var lastYear = date.clone().add(-1, 'year'); | |
if( Math.abs(nextYear.diff(moment(ref))) < Math.abs(date.diff(moment(ref))) ){ | |
date = nextYear; | |
} | |
else if( Math.abs(lastYear.diff(moment(ref))) < Math.abs(date.diff(moment(ref))) ){ | |
date = lastYear; | |
} | |
result.start.assign('day', date.date()); | |
result.start.assign('month', date.month() + 1); | |
result.start.imply('year', date.year()); | |
} | |
//Day of week | |
if(match[3]) { | |
result.start.assign('weekday', DAYS_OFFSET[match[3].toLowerCase()]); | |
} | |
if (match[5]) { | |
var endDay = parseInt(match[9]); | |
var startDay = parseInt(match[6]); | |
result.end = result.start.clone(); | |
result.start.assign('day', startDay); | |
result.end.assign('day', endDay); | |
var endDate = date.clone(); | |
date.date(startDay); | |
endDate.date(endDay); | |
} | |
result.index = index; | |
result.text = originalText; | |
result.ref = ref; | |
result.tags['ENMonthNameMiddleEndianParser'] = true; | |
return result; | |
} | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],9:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /(\W|^)(Sun|Sunday|Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thur|Thursday|Fri|Friday|Sat|Saturday)?\s*\,?\s*([0-9]{1,2})[\/\.]([0-9]{1,2})([\/\.]([0-9]{4}|[0-9]{2}))?(\W|$)/i; | |
var DAYS_OFFSET = { 'sunday': 0, 'sun': 0, 'monday': 1, 'mon': 1,'tuesday': 2, 'wednesday': 3, 'wed': 3, | |
'thursday': 4, 'thur': 4,'friday': 5, 'fri': 5,'saturday': 6, 'sat': 6,} | |
exports.Parser = function ENSlashDateFormatParser(argument) { | |
Parser.call(this); | |
this.pattern = function () { return PATTERN; }; | |
this.extract = function(text, ref, match, opt){ | |
if(match[1] == '/' || match[7] == '/') return; | |
var index = match.index + match[1].length; | |
var text = match[0].substr(match[1].length, match[0].length - match[7].length); | |
var result = new ParsedResult({ | |
text: text, | |
index: index, | |
ref: ref, | |
}); | |
if(text.match(/^\d.\d$/)) return; | |
// MM/dd -> OK | |
// MM.dd -> NG | |
if(!match[6] && match[0].indexOf('/') < 0) return; | |
var date = null; | |
var year = match[6] || moment(ref).year() + ''; | |
var month = match[3]; | |
var day = match[4]; | |
month = parseInt(month); | |
day = parseInt(day); | |
year = parseInt(year); | |
if(month < 1 || month > 12) return null; | |
if(day < 1 || day > 31) return null; | |
if(year < 100){ | |
if(year > 50){ | |
year = year + 2500 - 543; //BE | |
}else{ | |
year = year + 2000; //AD | |
} | |
} | |
text = month+'/'+day+'/'+year | |
date = moment(text,'M/D/YYYY'); | |
if(!date || date.date() != day || date.month() != (month-1)) { | |
return null; | |
} | |
result.start.assign('day', date.date()); | |
result.start.assign('month', date.month() + 1); | |
result.start.assign('year', date.year()); | |
//Day of week | |
if(match[2]) { | |
result.start.assign('weekday', DAYS_OFFSET[match[2].toLowerCase()]); | |
} | |
result.tags['ENSlashDateFormatParser'] = true; | |
return result; | |
}; | |
}; | |
},{"../../result":24,"../parser":15,"moment":1}],10:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /(\W|^)(?:within\s*)?([0-9]+)\s*(minutes?|hours?|days?)\s*ago(?=(?:\W|$))/i; | |
exports.Parser = function ENTimeAgoFormatParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
if (match.index > 0 && text[match.index-1].match(/\w/)) return null; | |
var text = match[0]; | |
text = match[0].substr(match[1].length, match[0].length - match[1].length); | |
index = match.index + match[1].length; | |
var result = new ParsedResult({ | |
index: index, | |
text: text, | |
ref: ref, | |
}); | |
var num = match[2]; | |
num = parseInt(num); | |
var date = moment(ref); | |
if (match[3].match(/day/)) { | |
impliedComponents = [] | |
date.add(-num, 'd'); | |
result.start.assign('day', date.date()); | |
result.start.assign('month', date.month() + 1); | |
result.start.assign('year', date.year()); | |
return result; | |
} | |
if (match[3].match(/hour/)) { | |
date.add(-num, 'hour'); | |
} else if (match[3].match(/minute/)) { | |
date.add(-num, 'minute'); | |
} | |
result.start.imply('day', date.date()); | |
result.start.imply('month', date.month() + 1); | |
result.start.imply('year', date.year()); | |
result.start.assign('hour', date.hour()); | |
result.start.assign('minute', date.minute()); | |
result.tags['ENTimeAgoFormatParser'] = true; | |
return result; | |
}; | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],11:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var FIRST_REG_PATTERN = new RegExp("(^|\\s|T)" + | |
"(?:(?:at|from)?\\s*)?" + | |
"(\\d{1,4}|noon|midnight)" + | |
"(?:" + | |
"(?:\\.|\\:|\\:)(\\d{1,2})" + | |
"(?:" + | |
"(?:\\.|\\:|\\:)(\\d{1,2})" + | |
")?" + | |
")?" + | |
"(?:\\s*(AM|PM|A\\.M\\.|P\\.M\\.))?" + | |
"(?=\\W|$)", 'i'); | |
var SECOND_REG_PATTERN = new RegExp("^\\s*" + | |
"(\\-|\\~|\\~|to|\\?)\\s*" + | |
"(\\d{1,4})" + | |
"(?:" + | |
"(?:\\.|\\:|\\:)(\\d{1,2})" + | |
"(?:" + | |
"(?:\\.|\\:|\\:)(\\d{1,2})" + | |
")?" + | |
")?" + | |
"(?:\\s*(AM|PM|A\\.M\\.|P\\.M\\.))?" + | |
"(?=\\W|$)", 'i'); | |
var HOUR_GROUP = 2; | |
var MINUTE_GROUP = 3; | |
var SECOND_GROUP = 4; | |
var AM_PM_HOUR_GROUP = 5; | |
exports.Parser = function ENTimeExpressionParser(){ | |
Parser.call(this); | |
this.pattern = function() { return FIRST_REG_PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
// This pattern can be overlaped Ex. [12] AM, 1[2] AM | |
if (match.index > 0 && text[match.index-1].match(/\w/)) return null; | |
var refMoment = moment(ref); | |
var result = new ParsedResult(); | |
result.ref = ref; | |
result.index = match.index + match[1].length; | |
result.text = match[0].substring(match[1].length); | |
result.tags['ENTimeExpressionParser'] = true; | |
result.start.imply('day', refMoment.date()); | |
result.start.imply('month', refMoment.month()+1); | |
result.start.imply('year', refMoment.year()); | |
var hour = 0; | |
var minute = 0; | |
var meridiem = -1; | |
// ----- Second | |
if(match[SECOND_GROUP] != null){ | |
var second = parseInt(match[SECOND_GROUP]); | |
if(second >= 60) return null; | |
result.start.assign('second', second); | |
} | |
// ----- Hours | |
if (match[HOUR_GROUP].toLowerCase() == "noon"){ | |
meridiem = 1; | |
hour = 12; | |
} else if (match[HOUR_GROUP].toLowerCase() == "midnight") { | |
meridiem = 0; | |
hour = 0; | |
} else { | |
hour = parseInt(match[HOUR_GROUP]); | |
} | |
// ----- Minutes | |
if(match[MINUTE_GROUP] != null){ | |
minute = parseInt(match[MINUTE_GROUP]); | |
} else if(hour > 100) { | |
minute = hour%100; | |
hour = parseInt(hour/100); | |
} | |
if(minute >= 60) { | |
return null; | |
} | |
if(hour > 24) { | |
return null; | |
} | |
if (hour >= 12) { | |
meridiem = 1; | |
} | |
// ----- AM & PM | |
if(match[AM_PM_HOUR_GROUP] != null) { | |
if(hour > 12) return null; | |
if(match[AM_PM_HOUR_GROUP].replace(".", "").toLowerCase() == "am"){ | |
meridiem = 0; | |
if(hour == 12) hour = 0; | |
} | |
if(match[AM_PM_HOUR_GROUP].replace(".", "").toLowerCase() == "pm"){ | |
meridiem = 1; | |
if(hour != 12) hour += 12; | |
} | |
} | |
result.start.assign('hour', hour); | |
result.start.assign('minute', minute); | |
if (meridiem >= 0) { | |
result.start.assign('meridiem', meridiem); | |
} | |
// ============================================================== | |
// Extracting the 'to' chunk | |
// ============================================================== | |
match = SECOND_REG_PATTERN.exec(text.substring(result.index + result.text.length)); | |
if (!match) { | |
// Not accept number only result | |
if (result.text.match(/^\d+$/)) { | |
return null; | |
} | |
return result; | |
} | |
if(result.end == null){ | |
result.end = result.start.clone(); | |
} | |
var hour = 0; | |
var minute = 0; | |
var meridiem = -1; | |
// ----- Second | |
if(match[SECOND_GROUP] != null){ | |
var second = parseInt(match[SECOND_GROUP]); | |
if(second >= 60) return null; | |
result.end.assign('second', second); | |
} | |
hour = parseInt(match[2]); | |
// ----- Minute | |
if (match[MINUTE_GROUP]!= null) { | |
minute = parseInt(match[MINUTE_GROUP]); | |
if(minute >= 60) return result; | |
} else if (hour > 100) { | |
minute = hour%100; | |
hour = parseInt(hour/100); | |
} | |
if(minute >= 60) { | |
return null; | |
} | |
if(hour > 24) { | |
return null; | |
} | |
if (hour >= 12) { | |
meridiem = 1; | |
} | |
// ----- AM & PM | |
if (match[AM_PM_HOUR_GROUP] != null){ | |
if (hour > 12) return null; | |
if(match[AM_PM_HOUR_GROUP].replace(".", "").toLowerCase() == "am"){ | |
meridiem = 0; | |
if(hour == 12) { | |
hour = 0; | |
if (!result.end.isCertain('day')) { | |
result.end.imply('day', result.end.get('day') + 1); | |
} | |
} | |
} | |
if(match[AM_PM_HOUR_GROUP].replace(".", "").toLowerCase() == "pm"){ | |
meridiem = 1; | |
if(hour != 12) hour += 12; | |
} | |
if (!result.start.isCertain('meridiem')) { | |
if (meridiem == 0) { | |
result.start.imply('meridiem', 0); | |
if (result.start.get('hour') == 12) { | |
result.start.assign('hour', 0); | |
} | |
} else { | |
result.start.imply('meridiem', 1); | |
if (result.start.get('hour') != 12) { | |
result.start.assign('hour', result.start.get('hour') + 12); | |
} | |
} | |
} | |
} | |
if(hour >= 12) meridiem = 1; | |
result.text = result.text + match[0]; | |
result.end.assign('hour', hour); | |
result.end.assign('minute', minute); | |
if (meridiem >= 0) { | |
result.end.assign('meridiem', meridiem); | |
} | |
return result; | |
} | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],12:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /(\W|^)((\,|\(|\()\s*)?((this|last|next)\s*)?(Sunday|Sun|Monday|Mon|Tuesday|Tues|Tue|Wednesday|Wed|Thursday|Thurs|Thur|Friday|Fri|Saturday|Sat)(\s*(\,|\)|\)))?(\W|$)/i; | |
var DAYS_OFFSET = { 'sunday': 0, 'sun': 0, 'monday': 1, 'mon': 1,'tuesday': 2, 'tues':2, 'tue':2, 'wednesday': 3, 'wed': 3, | |
'thursday': 4, 'thurs':4, 'thur': 4, 'thu': 4,'friday': 5, 'fri': 5,'saturday': 6, 'sat': 6,} | |
exports.Parser = function ENWeekdayParser() { | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var index = match.index + match[1].length; | |
var text = match[0].substr(match[1].length, match[0].length - match[9].length - match[1].length); | |
var result = new ParsedResult({ | |
index: index, | |
text: text, | |
ref: ref, | |
}); | |
var dayOfWeek = match[6].toLowerCase(); | |
var offset = DAYS_OFFSET[dayOfWeek]; | |
if(offset === undefined) return null; | |
var startMoment = moment(ref); | |
var prefix = match[5]; | |
if (prefix) { | |
prefix = prefix.toLowerCase(); | |
if(prefix == 'last') | |
startMoment.day(offset - 7) | |
else if(prefix == 'next') | |
startMoment.day(offset + 7) | |
else if(prefix== 'this') | |
startMoment.day(offset); | |
} | |
else{ | |
var refOffset = startMoment.day(); | |
if (Math.abs(offset - 7 - refOffset) < Math.abs(offset - refOffset)) { | |
startMoment.day(offset - 7); | |
} else if (Math.abs(offset + 7 - refOffset) < Math.abs(offset - refOffset)) { | |
startMoment.day(offset + 7); | |
} else { | |
startMoment.day(offset); | |
} | |
} | |
result.start.assign('weekday', offset); | |
result.start.imply('day', startMoment.date()) | |
result.start.imply('month', startMoment.month() + 1) | |
result.start.imply('year', startMoment.year()) | |
return result; | |
} | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],13:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var PATTERN = /今日|当日|昨日|明日|今夜|今夕|今晩|今朝/i; | |
exports.Parser = function JPCasualDateParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var index = match.index; | |
var text = match[0]; | |
var result = new ParsedResult({ | |
index: index, | |
text: text, | |
ref: ref, | |
}); | |
var refMoment = moment(ref); | |
var startMoment = refMoment.clone(); | |
if(text == '今夜' || text == '今夕' || text == '今晩'){ | |
// Normally means this coming midnight | |
result.start.imply('hour', 22); | |
result.start.imply('meridiem', 1); | |
} else if(text == '明日'){ | |
// Check not "Tomorrow" on late night | |
if(refMoment.hour() > 4) { | |
startMoment.add(1, 'day'); | |
} | |
} else if(text == '昨日') { | |
startMoment.add(-1, 'day'); | |
} else if (text.match("今朝")) { | |
result.start.imply('hour', 6); | |
result.start.imply('meridiem', 0); | |
} | |
result.start.assign('day', startMoment.date()) | |
result.start.assign('month', startMoment.month() + 1) | |
result.start.assign('year', startMoment.year()) | |
result.tags['JPCasualDateParser'] = true; | |
return result; | |
} | |
} | |
},{"../../result":24,"../parser":15,"moment":1}],14:[function(require,module,exports){ | |
/* | |
*/ | |
var moment = require('moment'); | |
var Parser = require('../parser').Parser; | |
var ParsedResult = require('../../result').ParsedResult; | |
var util = require('../../utils/JP'); | |
var PATTERN = /(?:(同|((昭和|平成)?([0-90-9]{2,4})))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i; | |
var YEAR_GROUP = 2; | |
var ERA_GROUP = 3; | |
var YEAR_NUMBER_GROUP = 4; | |
var MONTH_GROUP = 5; | |
var DAY_GROUP = 6; | |
exports.Parser = function JPStandardParser(){ | |
Parser.call(this); | |
this.pattern = function() { return PATTERN; } | |
this.extract = function(text, ref, match, opt){ | |
var startMoment = moment(ref); | |
var result = new ParsedResult({ | |
text: match[0], | |
index: match.index, | |
ref: ref, | |
}); | |
var month = match[MONTH_GROUP]; | |
month = util.toHankaku(month); | |
month = parseInt(month); | |
var day = match[DAY_GROUP]; | |
day = util.toHankaku(day); | |
day = parseInt(day); | |
startMoment.set('date', day); | |
startMoment.set('month', month - 1); | |
result.start.assign('day', startMoment.date()); | |
result.start.assign('month', startMoment.month() + 1); | |
if (!match[YEAR_GROUP]) { | |
//Find the most appropriated year | |
startMoment.year(moment(ref).year()); | |
var nextYear = startMoment.clone().add(1, 'y'); | |
var lastYear = startMoment.clone().add(-1, 'y'); | |
if( Math.abs(nextYear.diff(moment(ref))) < Math.abs(startMoment.diff(moment(ref))) ){ | |
startMoment = nextYear; | |
} | |
else if( Math.abs(lastYear.diff(moment(ref))) < Math.abs(startMoment.diff(moment(ref))) ){ | |
startMoment = lastYear; | |
} | |
result.start.assign('day', startMoment.date()); | |
result.start.assign('month', startMoment.month() + 1); | |
result.start.imply('year', startMoment.year()); | |
} else if (match[YEAR_GROUP].match('同年')) { | |
result.start.assign('year', startMoment.year()); | |
} else { | |
var year = match[YEAR_NUMBER_GROUP]; | |
year = util.toHankaku(year); | |
year = parseInt(year); | |
if (match[ERA_GROUP] == '平成') { | |
year += 1988; | |
} else if (match[ERA_GROUP] == '昭和') { | |
year += 1925; | |
} | |
result.start.assign('year', year); | |
} | |
result.tags['JPStandardParser'] = true; | |
return result; | |
}; | |
} | |
},{"../../result":24,"../../utils/JP":26,"../parser":15,"moment":1}],15:[function(require,module,exports){ | |
function Parser() { | |
this.pattern = function() { return /./i; } | |
this.extract = function(text, ref, match, opt){ return null; } | |
this.execute = function(text, ref, opt) { | |
var results = []; | |
var regex = this.pattern(); | |
var remainingText = text; | |
var match = regex.exec(remainingText); | |
while (match) { | |
// Calculate match index on the full text; | |
match.index += text.length - remainingText.length; | |
var result = this.extract(text, ref, match, opt); | |
if (result) { | |
// If success, start from the end of the result | |
remainingText = text.substring(result.index + result.text.length); | |
results.push(result); | |
} else { | |
// If fail, move on by 1 | |
remainingText = text.substring(match.index + 1); | |
} | |
match = regex.exec(remainingText); | |
} | |
if (this.refiners) { | |
this.refiners.forEach(function () { | |
results = refiner.refine(results, text, options); | |
}); | |
} | |
return results; | |
} | |
} | |
exports.Parser = Parser; | |
},{}],16:[function(require,module,exports){ | |
/* | |
*/ | |
var Refiner = require('../refiner').Refiner; | |
exports.Refiner = function ENMergeDateRangeRefiner() { | |
Refiner.call(this); | |
this.pattern = function () { return /^\s*(to|\-)\s*$/i }; | |
this.refine = function(text, results, opt) { | |
if (results.length < 2) return results; | |
var mergedResult = [] | |
var currResult = null; | |
var prevResult = null; | |
for (var i=1; i<results.length; i++){ | |
currResult = results[i]; | |
prevResult = results[i-1]; | |
if (!prevResult.end && !currResult.end | |
&& this.isAbleToMerge(text, prevResult, currResult)) { | |
prevResult = this.mergeResult(text, prevResult, currResult); | |
currResult = null; | |
i += 1; | |
} | |
mergedResult.push(prevResult); | |
} | |
if (currResult != null) { | |
mergedResult.push(currResult); | |
} | |
return mergedResult; | |
} | |
this.isAbleToMerge = function(text, result1, result2) { | |
var begin = result1.index + result1.text.length; | |
var end = result2.index; | |
var textBetween = text.substring(begin,end); | |
return textBetween.match(this.pattern()); | |
} | |
this.mergeResult = function(text, fromResult, toResult) { | |
for (var key in toResult.start.knownValues) { | |
if (!fromResult.start.isCertain(key)) { | |
fromResult.start.assign(key, toResult.start.get(key)); | |
} | |
} | |
for (var key in fromResult.start.knownValues) { | |
if (!toResult.start.isCertain(key)) { | |
toResult.start.assign(key, fromResult.start.get(key)); | |
} | |
} | |
if (fromResult.start.date().getTime() > toResult.start.date()) { | |
var tmp = toResult; | |
toResult = fromResult; | |
fromResult = tmp; | |
} | |
fromResult.end = toResult.start; | |
for (var tag in toResult.tags) { | |
fromResult.tags[tag] = true; | |
} | |
var startIndex = Math.min(fromResult.index, toResult.index); | |
var endIndex = Math.max( | |
fromResult.index + fromResult.text.length, | |
toResult.index + toResult.text.length); | |
fromResult.index = startIndex; | |
fromResult.text = text.substring(startIndex, endIndex); | |
fromResult.tags[this.constructor.name] = true; | |
return fromResult; | |
} | |
} | |
},{"../refiner":23}],17:[function(require,module,exports){ | |
/* | |
*/ | |
var ParsedComponents = require('../../result').ParsedComponents; | |
var Refiner = require('../refiner').Refiner; | |
var PATTERN = new RegExp("^\\s*(T|at|on|of|,|-)?\\s*$"); | |
function isDateOnly(result) { | |
return !result.start.isCertain('hour'); | |
} | |
function isTimeOnly(result) { | |
return !result.start.isCertain('month') && !result.start.isCertain('weekday'); | |
} | |
function isAbleToMerge(text, prevResult, curResult) { | |
var textBetween = text.substring(prevResult.index + prevResult.text.length, curResult.index); | |
return textBetween.match(PATTERN); | |
} | |
function mergeResult(text, dateResult, timeResult){ | |
var beginDate = dateResult.start; | |
var beginTime = timeResult.start; | |
var beginDateTime = beginDate.clone(); | |
beginDateTime.assign('hour', beginTime.get('hour')); | |
beginDateTime.assign('minute', beginTime.get('minute')); | |
beginDateTime.assign('second', beginTime.get('second')); | |
if (beginTime.isCertain('meridiem')) { | |
beginDateTime.assign('meridiem', beginTime.get('meridiem')); | |
} else if (beginTime.get('meridiem') !== undefined) { | |
beginDateTime.imply('meridiem', beginTime.get('meridiem')); | |
} | |
if (beginDateTime.get('meridiem') == 1 && beginDateTime.get('hour') < 12) { | |
beginDateTime.assign('hour', beginDateTime.get('hour') + 12); | |
} | |
dateResult.start = beginDateTime; | |
if (dateResult.end != null || timeResult.end != null) { | |
var endDate = dateResult.end == null ? dateResult.start : dateResult.end; | |
var endTime = timeResult.end == null ? timeResult.start : timeResult.end; | |
var endDateTime = endDate.clone(); | |
endDateTime.assign('hour', endTime.get('hour')); | |
endDateTime.assign('minute', endTime.get('minute')); | |
endDateTime.assign('second', endTime.get('second')); | |
if (endTime.isCertain('meridiem')) { | |
endDateTime.assign('meridiem', endTime.get('meridiem')); | |
} else if (beginTime.get('meridiem') != null) { | |
endDateTime.imply('meridiem', endTime.get('meridiem')); | |
} | |
dateResult.end = endDateTime; | |
} | |
var startIndex = Math.min(dateResult.index, timeResult.index); | |
var endIndex = Math.max( | |
dateResult.index + dateResult.text.length, | |
timeResult.index + timeResult.text.length); | |
dateResult.index = startIndex; | |
dateResult.text = text.substring(startIndex, endIndex); | |
for (var tag in timeResult.tags) { | |
dateResult.tags[tag] = true; | |
} | |
dateResult.tags['ENMergeDateAndTimeRefiner'] = true; | |
return dateResult; | |
} | |
exports.Refiner = function ENMergeDateTimeRefiner() { | |
Refiner.call(this); | |
this.refine = function(text, results, opt) { | |
if (results.length < 2) return results; | |
var mergedResult = []; | |
var currResult = null; | |
var prevResult = null; | |
for (var i = 1; i < results.length; i++) { | |
currResult = results[i]; | |
prevResult = results[i-1]; | |
if (isDateOnly(prevResult) && isTimeOnly(currResult) | |
&& isAbleToMerge(text, prevResult, currResult)) { | |
prevResult = mergeResult(text, prevResult, currResult); | |
currResult = null; | |
i += 1; | |
} else if (isDateOnly(currResult) && isTimeOnly(prevResult) | |
&& isAbleToMerge(text, prevResult, currResult)) { | |
prevResult = mergeResult(text, currResult, prevResult); | |
currResult = null; | |
i += 1; | |
} | |
mergedResult.push(prevResult); | |
} | |
if (currResult != null) { | |
mergedResult.push(currResult); | |
} | |
return mergedResult; | |
} | |
} | |
},{"../../result":24,"../refiner":23}],18:[function(require,module,exports){ | |
/* | |
*/ | |
var Refiner = require('./refiner').Refiner; | |
// Map ABBR -> Offset in minute | |
var TIMEZONE_ABBR_MAP = {}; | |
var TIMEZONE_NAME_PATTERN = new RegExp("^\\s*\\(?([A-Z]{1,4})\\)?(?=\\W|$)", 'i'); | |
exports.Refiner = function ExtractTimezoneAbbrRefiner() { | |
Refiner.call(this); | |
this.refine = function(text, results, opt) { | |
results.forEach(function(result) { | |
var match = TIMEZONE_NAME_PATTERN.exec(text.substring(result.index + result.text.length)); | |
if (match) { | |
var timezoneAbbr = match[1]; | |
if (TIMEZONE_ABBR_MAP[timezoneAbbr] === undefined) { | |
return; | |
} | |
var timezoneOffset = TIMEZONE_ABBR_MAP[timezoneAbbr]; | |
if (!result.start.isCertain('timezoneOffset')) { | |
result.start.assign('timezoneOffset', timezoneOffset); | |
} | |
if (result.end != null && !result.end.isCertain('timezoneOffset')) { | |
result.end.assign('timezoneOffset', timezoneOffset); | |
} | |
result.text += match[0]; | |
result.tags['ExtractTimezoneAbbrRefiner'] = true; | |
} | |
}); | |
return results; | |
} | |
} | |
// TODO: Move this to some configuration | |
TIMEZONE_ABBR_MAP = {"A":60,"ACDT":630,"ACST":570,"ADT":-180,"AEDT":660,"AEST":600,"AFT":270,"AKDT":-480,"AKST":-540,"ALMT":360,"AMST":-180,"AMT":-240,"ANAST":720,"ANAT":720,"AQTT":300,"ART":-180,"AST":-240,"AWDT":540,"AWST":480,"AZOST":0,"AZOT":-60,"AZST":300,"AZT":240,"B":120,"BNT":480,"BOT":-240,"BRST":-120,"BRT":-180,"BST":60,"BTT":360,"C":180,"CAST":480,"CAT":120,"CCT":390,"CDT":-300,"CEST":120,"CET":60,"CHADT":825,"CHAST":765,"CKT":-600,"CLST":-180,"CLT":-240,"COT":-300,"CST":-360,"CVT":-60,"CXT":420,"ChST":600,"D":240,"DAVT":420,"E":300,"EASST":-300,"EAST":-360,"EAT":180,"ECT":-300,"EDT":-240,"EEST":180,"EET":120,"EGST":0,"EGT":-60,"EST":-300,"ET":-300,"F":360,"FJST":780,"FJT":720,"FKST":-180,"FKT":-240,"FNT":-120,"G":420,"GALT":-360,"GAMT":-540,"GET":240,"GFT":-180,"GILT":720,"GMT":0,"GST":240,"GYT":-240,"H":480,"HAA":-180,"HAC":-300,"HADT":-540,"HAE":-240,"HAP":-420,"HAR":-360,"HAST":-600,"HAT":-90,"HAY":-480,"HKT":480,"HLV":-210,"HNA":-240,"HNC":-360,"HNE":-300,"HNP":-480,"HNR":-420,"HNT":-150,"HNY":-540,"HOVT":420,"I":540,"ICT":420,"IDT":180,"IOT":360,"IRDT":270,"IRKST":540,"IRKT":540,"IRST":210,"IST":60,"JST":540,"K":600,"KGT":360,"KRAST":480,"KRAT":480,"KST":540,"KUYT":240,"L":660,"LHDT":660,"LHST":630,"LINT":840,"M":720,"MAGST":720,"MAGT":720,"MART":-510,"MAWT":300,"MDT":-360,"MESZ":120,"MEZ":60,"MHT":720,"MMT":390,"MSD":240,"MSK":240,"MST":-420,"MUT":240,"MVT":300,"MYT":480,"N":-60,"NCT":660,"NDT":-90,"NFT":690,"NOVST":420,"NOVT":360,"NPT":345,"NST":-150,"NUT":-660,"NZDT":780,"NZST":720,"O":-120,"OMSST":420,"OMST":420,"P":-180,"PDT":-420,"PET":-300,"PETST":720,"PETT":720,"PGT":600,"PHOT":780,"PHT":480,"PKT":300,"PMDT":-120,"PMST":-180,"PONT":660,"PST":-480,"PT":-480,"PWT":540,"PYST":-180,"PYT":-240,"Q":-240,"R":-300,"RET":240,"S":-360,"SAMT":240,"SAST":120,"SBT":660,"SCT":240,"SGT":480,"SRT":-180,"SST":-660,"T":-420,"TAHT":-600,"TFT":300,"TJT":300,"TKT":780,"TLT":540,"TMT":300,"TVT":720,"U":-480,"ULAT":480,"UTC":0,"UYST":-120,"UYT":-180,"UZT":300,"V":-540,"VET":-210,"VLAST":660,"VLAT":660,"VUT":660,"W":-600,"WAST":120,"WAT":60,"WEST":60,"WESZ":60,"WET":0,"WEZ":0,"WFT":720,"WGST":-120,"WGT":-180,"WIB":420,"WIT":540,"WITA":480,"WST":780,"WT":0,"X":-660,"Y":-720,"YAKST":600,"YAKT":600,"YAPT":600,"YEKST":360,"YEKT":360,"Z":0} | |
},{"./refiner":23}],19:[function(require,module,exports){ | |
/* | |
*/ | |
var Refiner = require('./refiner').Refiner; | |
var TIMEZONE_OFFSET_PATTERN = new RegExp("^\\s*(GMT|UTC)?(\\+|\\-)(\\d{1,2}):?(\\d{2})", 'i'); | |
var TIMEZONE_OFFSET_SIGN_GROUP = 2; | |
var TIMEZONE_OFFSET_HOUR_OFFSET_GROUP = 3; | |
var TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP = 4; | |
exports.Refiner = function ExtractTimezoneOffsetRefiner() { | |
Refiner.call(this); | |
this.refine = function(text, results, opt) { | |
results.forEach(function(result) { | |
if (result.start.isCertain('timezoneOffset')) { | |
return; | |
} | |
var match = TIMEZONE_OFFSET_PATTERN.exec(text.substring(result.index + result.text.length)); | |
if (!match) { | |
return; | |
} | |
var hourOffset = parseInt(match[TIMEZONE_OFFSET_HOUR_OFFSET_GROUP]); | |
var minuteOffset = parseInt(match[TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP]); | |
var timezoneOffset = hourOffset * 60 + minuteOffset; | |
if (match[TIMEZONE_OFFSET_SIGN_GROUP] === '-') { | |
timezoneOffset = -timezoneOffset; | |
} | |
if (result.end != null) { | |
result.end.assign('timezoneOffset', timezoneOffset); | |
} | |
result.start.assign('timezoneOffset', timezoneOffset); | |
result.text += match[0]; | |
result.tags['ExtractTimezoneOffsetRefiner'] = true; | |
}); | |
return results; | |
} | |
} | |
},{"./refiner":23}],20:[function(require,module,exports){ | |
/* | |
*/ | |
var ENMergeDateRangeRefiner = require('../EN/ENMergeDateRangeRefiner').Refiner; | |
exports.Refiner = function JPMergeDateRangeRefiner() { | |
ENMergeDateRangeRefiner.call(this); | |
this.pattern = function () { return /^\s*(から|ー)\s*$/i }; | |
} | |
},{"../EN/ENMergeDateRangeRefiner":16}],21:[function(require,module,exports){ | |
/* | |
*/ | |
var Refiner = require('./refiner').Refiner; | |
exports.Refiner = function OverlapRemovalRefiner() { | |
Refiner.call(this); | |
this.refine = function(text, results, opt) { | |
if (results.length < 2) return results; | |
var filteredResults = []; | |
var prevResult = results[0]; | |
for (var i=1; i<results.length; i++){ | |
var result = results[i]; | |
// If overlap, compare the length and discard the shorter one | |
if (result.index < prevResult.index + prevResult.text.length) { | |
if (result.text.length > prevResult.text.length){ | |
prevResult = result; | |
} | |
} else { | |
filteredResults.push(prevResult); | |
prevResult = result; | |
} | |
} | |
// The last one | |
if (prevResult != null) { | |
filteredResults.push(prevResult); | |
} | |
return filteredResults; | |
} | |
} | |
},{"./refiner":23}],22:[function(require,module,exports){ | |
/* | |
*/ | |
var Filter = require('./refiner').Filter; | |
exports.Refiner = function UnlikelyFormatFilter() { | |
Filter.call(this); | |
this.isValid = function(text, result, opt) { | |
if (result.text.replace(' ','').match(/^\d*(\.\d*)?$/)) { | |
return false; | |
} | |
return true; | |
} | |
} | |
},{"./refiner":23}],23:[function(require,module,exports){ | |
/* | |
*/ | |
exports.Refiner = function Refiner() { | |
this.refine = function(text, results, opt) { return results; }; | |
} | |
exports.Filter = function Filter() { | |
exports.Refiner.call(this); | |
this.isValid = function(text, result, opt) { return true; } | |
this.refine = function(text, results, opt) { | |
var filteredResult = []; | |
for (var i=0; i < results.length; i++) { | |
var result = results[i]; | |
if (this.isValid(text, result, opt)) { | |
filteredResult.push(result); | |
} | |
} | |
return filteredResult; | |
} | |
} | |
},{}],24:[function(require,module,exports){ | |
var moment = require('moment'); | |
function ParsedResult(result){ | |
result = result || {}; | |
this.ref = result.ref; | |
this.index = result.index; | |
this.text = result.text; | |
this.tags = result.tags || {}; | |
this.start = new ParsedComponents(result.start, result.ref) | |
if(result.end){ | |
this.end = new ParsedComponents(result.end, result.ref) | |
} | |
} | |
ParsedResult.prototype.clone = function() { | |
var result = new ParsedResult(this); | |
result.tags = JSON.parse(JSON.stringify(this.tags)); | |
result.start = this.start.clone(); | |
if (this.end) { | |
result.end = this.end.clone(); | |
} | |
} | |
function ParsedComponents (components, ref){ | |
this.knownValues = {}; | |
this.impliedValues = {}; | |
if (components) { | |
for (key in components) { | |
this.knownValues[key] = components[key]; | |
} | |
} | |
if (ref) { | |
ref = moment(ref); | |
this.imply('day', ref.date()) | |
this.imply('month', ref.month() + 1) | |
this.imply('year', ref.year()) | |
} | |
this.imply('hour', 12); | |
this.imply('minute', 0); | |
this.imply('second', 0); | |
} | |
ParsedComponents.prototype.clone = function () { | |
var component = new ParsedComponents(); | |
component.knownValues = JSON.parse(JSON.stringify(this.knownValues)); | |
component.impliedValues = JSON.parse(JSON.stringify(this.impliedValues)); | |
return component; | |
} | |
ParsedComponents.prototype.get = function(component, value) { | |
if (component in this.knownValues) return this.knownValues[component]; | |
if (component in this.impliedValues) return this.impliedValues[component]; | |
}; | |
ParsedComponents.prototype.assign = function(component, value) { | |
this.knownValues[component] = value; | |
delete this.impliedValues[component]; | |
}; | |
ParsedComponents.prototype.imply = function(component, value) { | |
if (component in this.knownValues) return; | |
this.impliedValues[component] = value; | |
}; | |
ParsedComponents.prototype.isCertain = function(component) { | |
return component in this.knownValues; | |
}; | |
ParsedComponents.prototype.date = function() { | |
var dateMoment = moment(); | |
dateMoment.set('year', this.get('year')); | |
dateMoment.set('month', this.get('month')-1); | |
dateMoment.set('date', this.get('day')); | |
dateMoment.set('hour', this.get('hour')); | |
dateMoment.set('minute', this.get('minute')); | |
dateMoment.set('second', this.get('second')); | |
// Javascript Date Object return minus timezone offset | |
var currentTimezoneOffset = -new Date().getTimezoneOffset(); | |
var targetTimezoneOffset = this.isCertain('timezoneOffset') ? | |
this.get('timezoneOffset') : currentTimezoneOffset; | |
var adjustTimezoneOffset = targetTimezoneOffset - currentTimezoneOffset; | |
dateMoment.add(-adjustTimezoneOffset, 'minutes'); | |
return dateMoment.toDate(); | |
}; | |
exports.ParsedComponents = ParsedComponents; | |
exports.ParsedResult = ParsedResult; | |
},{"moment":1}],25:[function(require,module,exports){ | |
exports.WEEKDAY_OFFSET = { | |
'sunday': 0, | |
'sun': 0, | |
'monday': 1, | |
'mon': 1, | |
'tuesday': 2, | |
'tue':2, | |
'wednesday': 3, | |
'wed': 3, | |
'thursday': 4, | |
'thur': 4, | |
'thu': 4, | |
'friday': 5, | |
'fri': 5, | |
'saturday': 6, | |
'sat': 6,} | |
exports.MONTH_OFFSET = { | |
'january': 1, | |
'jan': 1, | |
'jan.': 1, | |
'february': 2, | |
'feb': 2, | |
'feb.': 2, | |
'march': 3, | |
'mar': 3, | |
'mar.': 3, | |
'april': 4, | |
'apr': 4, | |
'apr.': 4, | |
'may': 5, | |
'june': 6, | |
'jun': 6, | |
'jun.': 6, | |
'july': 7, | |
'jul': 7, | |
'jul.': 7, | |
'august': 8, | |
'aug': 8, | |
'aug.': 8, | |
'september': 9, | |
'sep': 9, | |
'sep.': 9, | |
'october': 10, | |
'oct': 10, | |
'oct.': 10, | |
'november': 11, | |
'nov': 11, | |
'nov.': 11, | |
'december': 12, | |
'dec': 12, | |
'dec.': 12, | |
} | |
},{}],26:[function(require,module,exports){ | |
/** | |
* to-hankaku.js | |
* convert to ascii code strings. | |
* | |
* @version 1.0.1 | |
* @author think49 | |
* @url https://gist.github.com/964592 | |
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License) | |
*/ | |
exports.toHankaku = (function (String, fromCharCode) { | |
function toHankaku (string) { | |
return String(string).replace(/\u2019/g, '\u0027').replace(/\u201D/g, '\u0022').replace(/\u3000/g, '\u0020').replace(/\uFFE5/g, '\u00A5').replace(/[\uFF01\uFF03-\uFF06\uFF08\uFF09\uFF0C-\uFF19\uFF1C-\uFF1F\uFF21-\uFF3B\uFF3D\uFF3F\uFF41-\uFF5B\uFF5D\uFF5E]/g, alphaNum); | |
} | |
function alphaNum (token) { | |
return fromCharCode(token.charCodeAt(0) - 65248); | |
} | |
return toHankaku; | |
})(String, String.fromCharCode); | |
/** | |
* to-zenkaku.js | |
* convert to multi byte strings. | |
* | |
* @version 1.0.2 | |
* @author think49 | |
* @url https://gist.github.com/964592 | |
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License) | |
*/ | |
exports.toZenkaku = (function (String, fromCharCode) { | |
function toZenkaku (string) { | |
return String(string).replace(/\u0020/g, '\u3000').replace(/\u0022/g, '\u201D').replace(/\u0027/g, '\u2019').replace(/\u00A5/g, '\uFFE5').replace(/[!#-&(),-9\u003C-?A-[\u005D_a-{}~]/g, alphaNum); | |
} | |
function alphaNum (token) { | |
return fromCharCode(token.charCodeAt(0) + 65248); | |
} | |
return toZenkaku; | |
})(String, String.fromCharCode); | |
},{}]},{},[2])(2) | |
}); | |
(function(a){function b(a,b,c){switch(arguments.length){case 2:return null!=a?a:b;case 3:return null!=a?a:null!=b?b:c;default:throw new Error("Implement me")}}function c(a,b){return Bb.call(a,b)}function d(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function e(a){vb.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+a)}function f(a,b){var c=!0;return o(function(){return c&&(e(a),c=!1),b.apply(this,arguments)},b)}function g(a,b){sc[a]||(e(b),sc[a]=!0)}function h(a,b){return function(c){return r(a.call(this,c),b)}}function i(a,b){return function(c){return this.localeData().ordinal(a.call(this,c),b)}}function j(a,b){var c,d,e=12*(b.year()-a.year())+(b.month()-a.month()),f=a.clone().add(e,"months");return 0>b-f?(c=a.clone().add(e-1,"months"),d=(b-f)/(f-c)):(c=a.clone().add(e+1,"months"),d=(b-f)/(c-f)),-(e+d)}function k(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&12>b&&(b+=12),d||12!==b||(b=0),b):b}function l(){}function m(a,b){b!==!1&&H(a),p(this,a),this._d=new Date(+a._d),uc===!1&&(uc=!0,vb.updateOffset(this),uc=!1)}function n(a){var b=A(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;this._milliseconds=+k+1e3*j+6e4*i+36e5*h,this._days=+g+7*f,this._months=+e+3*d+12*c,this._data={},this._locale=vb.localeData(),this._bubble()}function o(a,b){for(var d in b)c(b,d)&&(a[d]=b[d]);return c(b,"toString")&&(a.toString=b.toString),c(b,"valueOf")&&(a.valueOf=b.valueOf),a}function p(a,b){var c,d,e;if("undefined"!=typeof b._isAMomentObject&&(a._isAMomentObject=b._isAMomentObject),"undefined"!=typeof b._i&&(a._i=b._i),"undefined"!=typeof b._f&&(a._f=b._f),"undefined"!=typeof b._l&&(a._l=b._l),"undefined"!=typeof b._strict&&(a._strict=b._strict),"undefined"!=typeof b._tzm&&(a._tzm=b._tzm),"undefined"!=typeof b._isUTC&&(a._isUTC=b._isUTC),"undefined"!=typeof b._offset&&(a._offset=b._offset),"undefined"!=typeof b._pf&&(a._pf=b._pf),"undefined"!=typeof b._locale&&(a._locale=b._locale),Kb.length>0)for(c in Kb)d=Kb[c],e=b[d],"undefined"!=typeof e&&(a[d]=e);return a}function q(a){return 0>a?Math.ceil(a):Math.floor(a)}function r(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function s(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function t(a,b){var c;return b=M(b,a),a.isBefore(b)?c=s(a,b):(c=s(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c}function u(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(g(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=vb.duration(c,d),v(this,e,a),this}}function v(a,b,c,d){var e=b._milliseconds,f=b._days,g=b._months;d=null==d?!0:d,e&&a._d.setTime(+a._d+e*c),f&&pb(a,"Date",ob(a,"Date")+f*c),g&&nb(a,ob(a,"Month")+g*c),d&&vb.updateOffset(a,f||g)}function w(a){return"[object Array]"===Object.prototype.toString.call(a)}function x(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function y(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&C(a[d])!==C(b[d]))&&g++;return g+f}function z(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=lc[a]||mc[b]||b}return a}function A(a){var b,d,e={};for(d in a)c(a,d)&&(b=z(d),b&&(e[b]=a[d]));return e}function B(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}vb[b]=function(e,f){var g,h,i=vb._locale[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=vb().utc().set(d,a);return i.call(vb._locale,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function C(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function D(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function E(a,b,c){return jb(vb([a,11,31+b-c]),b,c).week}function F(a){return G(a)?366:365}function G(a){return a%4===0&&a%100!==0||a%400===0}function H(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[Db]<0||a._a[Db]>11?Db:a._a[Eb]<1||a._a[Eb]>D(a._a[Cb],a._a[Db])?Eb:a._a[Fb]<0||a._a[Fb]>24||24===a._a[Fb]&&(0!==a._a[Gb]||0!==a._a[Hb]||0!==a._a[Ib])?Fb:a._a[Gb]<0||a._a[Gb]>59?Gb:a._a[Hb]<0||a._a[Hb]>59?Hb:a._a[Ib]<0||a._a[Ib]>999?Ib:-1,a._pf._overflowDayOfYear&&(Cb>b||b>Eb)&&(b=Eb),a._pf.overflow=b)}function I(b){return null==b._isValid&&(b._isValid=!isNaN(b._d.getTime())&&b._pf.overflow<0&&!b._pf.empty&&!b._pf.invalidMonth&&!b._pf.nullInput&&!b._pf.invalidFormat&&!b._pf.userInvalidated,b._strict&&(b._isValid=b._isValid&&0===b._pf.charsLeftOver&&0===b._pf.unusedTokens.length&&b._pf.bigHour===a)),b._isValid}function J(a){return a?a.toLowerCase().replace("_","-"):a}function K(a){for(var b,c,d,e,f=0;f<a.length;){for(e=J(a[f]).split("-"),b=e.length,c=J(a[f+1]),c=c?c.split("-"):null;b>0;){if(d=L(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&y(e,c,!0)>=b-1)break;b--}f++}return null}function L(a){var b=null;if(!Jb[a]&&Lb)try{b=vb.locale(),require("./locale/"+a),vb.locale(b)}catch(c){}return Jb[a]}function M(a,b){var c,d;return b._isUTC?(c=b.clone(),d=(vb.isMoment(a)||x(a)?+a:+vb(a))-+c,c._d.setTime(+c._d+d),vb.updateOffset(c,!1),c):vb(a).local()}function N(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function O(a){var b,c,d=a.match(Pb);for(b=0,c=d.length;c>b;b++)d[b]=rc[d[b]]?rc[d[b]]:N(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function P(a,b){return a.isValid()?(b=Q(b,a.localeData()),nc[b]||(nc[b]=O(b)),nc[b](a)):a.localeData().invalidDate()}function Q(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Qb.lastIndex=0;d>=0&&Qb.test(a);)a=a.replace(Qb,c),Qb.lastIndex=0,d-=1;return a}function R(a,b){var c,d=b._strict;switch(a){case"Q":return _b;case"DDDD":return bc;case"YYYY":case"GGGG":case"gggg":return d?cc:Tb;case"Y":case"G":case"g":return ec;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?dc:Ub;case"S":if(d)return _b;case"SS":if(d)return ac;case"SSS":if(d)return bc;case"DDD":return Sb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Wb;case"a":case"A":return b._locale._meridiemParse;case"x":return Zb;case"X":return $b;case"Z":case"ZZ":return Xb;case"T":return Yb;case"SSSS":return Vb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?ac:Rb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Rb;case"Do":return d?b._locale._ordinalParse:b._locale._ordinalParseLenient;default:return c=new RegExp($(Z(a.replace("\\","")),"i"))}}function S(a){a=a||"";var b=a.match(Xb)||[],c=b[b.length-1]||[],d=(c+"").match(jc)||["-",0,0],e=+(60*d[1])+C(d[2]);return"+"===d[0]?e:-e}function T(a,b,c){var d,e=c._a;switch(a){case"Q":null!=b&&(e[Db]=3*(C(b)-1));break;case"M":case"MM":null!=b&&(e[Db]=C(b)-1);break;case"MMM":case"MMMM":d=c._locale.monthsParse(b,a,c._strict),null!=d?e[Db]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[Eb]=C(b));break;case"Do":null!=b&&(e[Eb]=C(parseInt(b.match(/\d{1,2}/)[0],10)));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=C(b));break;case"YY":e[Cb]=vb.parseTwoDigitYear(b);break;case"YYYY":case"YYYYY":case"YYYYYY":e[Cb]=C(b);break;case"a":case"A":c._meridiem=b;break;case"h":case"hh":c._pf.bigHour=!0;case"H":case"HH":e[Fb]=C(b);break;case"m":case"mm":e[Gb]=C(b);break;case"s":case"ss":e[Hb]=C(b);break;case"S":case"SS":case"SSS":case"SSSS":e[Ib]=C(1e3*("0."+b));break;case"x":c._d=new Date(C(b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=S(b);break;case"dd":case"ddd":case"dddd":d=c._locale.weekdaysParse(b),null!=d?(c._w=c._w||{},c._w.d=d):c._pf.invalidWeekday=b;break;case"w":case"ww":case"W":case"WW":case"d":case"e":case"E":a=a.substr(0,1);case"gggg":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=C(b));break;case"gg":case"GG":c._w=c._w||{},c._w[a]=vb.parseTwoDigitYear(b)}}function U(a){var c,d,e,f,g,h,i;c=a._w,null!=c.GG||null!=c.W||null!=c.E?(g=1,h=4,d=b(c.GG,a._a[Cb],jb(vb(),1,4).year),e=b(c.W,1),f=b(c.E,1)):(g=a._locale._week.dow,h=a._locale._week.doy,d=b(c.gg,a._a[Cb],jb(vb(),g,h).year),e=b(c.w,1),null!=c.d?(f=c.d,g>f&&++e):f=null!=c.e?c.e+g:g),i=kb(d,e,f,h,g),a._a[Cb]=i.year,a._dayOfYear=i.dayOfYear}function V(a){var c,d,e,f,g=[];if(!a._d){for(e=X(a),a._w&&null==a._a[Eb]&&null==a._a[Db]&&U(a),a._dayOfYear&&(f=b(a._a[Cb],e[Cb]),a._dayOfYear>F(f)&&(a._pf._overflowDayOfYear=!0),d=fb(f,0,a._dayOfYear),a._a[Db]=d.getUTCMonth(),a._a[Eb]=d.getUTCDate()),c=0;3>c&&null==a._a[c];++c)a._a[c]=g[c]=e[c];for(;7>c;c++)a._a[c]=g[c]=null==a._a[c]?2===c?1:0:a._a[c];24===a._a[Fb]&&0===a._a[Gb]&&0===a._a[Hb]&&0===a._a[Ib]&&(a._nextDay=!0,a._a[Fb]=0),a._d=(a._useUTC?fb:eb).apply(null,g),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[Fb]=24)}}function W(a){var b;a._d||(b=A(a._i),a._a=[b.year,b.month,b.day||b.date,b.hour,b.minute,b.second,b.millisecond],V(a))}function X(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function Y(b){if(b._f===vb.ISO_8601)return void ab(b);b._a=[],b._pf.empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,j=0;for(e=Q(b._f,b._locale).match(Pb)||[],c=0;c<e.length;c++)f=e[c],d=(h.match(R(f,b))||[])[0],d&&(g=h.substr(0,h.indexOf(d)),g.length>0&&b._pf.unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),j+=d.length),rc[f]?(d?b._pf.empty=!1:b._pf.unusedTokens.push(f),T(f,d,b)):b._strict&&!d&&b._pf.unusedTokens.push(f);b._pf.charsLeftOver=i-j,h.length>0&&b._pf.unusedInput.push(h),b._pf.bigHour===!0&&b._a[Fb]<=12&&(b._pf.bigHour=a),b._a[Fb]=k(b._locale,b._a[Fb],b._meridiem),V(b),H(b)}function Z(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function $(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function _(a){var b,c,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;f<a._f.length;f++)g=0,b=p({},a),null!=a._useUTC&&(b._useUTC=a._useUTC),b._pf=d(),b._f=a._f[f],Y(b),I(b)&&(g+=b._pf.charsLeftOver,g+=10*b._pf.unusedTokens.length,b._pf.score=g,(null==e||e>g)&&(e=g,c=b));o(a,c||b)}function ab(a){var b,c,d=a._i,e=fc.exec(d);if(e){for(a._pf.iso=!0,b=0,c=hc.length;c>b;b++)if(hc[b][1].exec(d)){a._f=hc[b][0]+(e[6]||" ");break}for(b=0,c=ic.length;c>b;b++)if(ic[b][1].exec(d)){a._f+=ic[b][0];break}d.match(Xb)&&(a._f+="Z"),Y(a)}else a._isValid=!1}function bb(a){ab(a),a._isValid===!1&&(delete a._isValid,vb.createFromInputFallback(a))}function cb(a,b){var c,d=[];for(c=0;c<a.length;++c)d.push(b(a[c],c));return d}function db(b){var c,d=b._i;d===a?b._d=new Date:x(d)?b._d=new Date(+d):null!==(c=Mb.exec(d))?b._d=new Date(+c[1]):"string"==typeof d?bb(b):w(d)?(b._a=cb(d.slice(0),function(a){return parseInt(a,10)}),V(b)):"object"==typeof d?W(b):"number"==typeof d?b._d=new Date(d):vb.createFromInputFallback(b)}function eb(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function fb(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function gb(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function hb(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function ib(a,b,c){var d=vb.duration(a).abs(),e=Ab(d.as("s")),f=Ab(d.as("m")),g=Ab(d.as("h")),h=Ab(d.as("d")),i=Ab(d.as("M")),j=Ab(d.as("y")),k=e<oc.s&&["s",e]||1===f&&["m"]||f<oc.m&&["mm",f]||1===g&&["h"]||g<oc.h&&["hh",g]||1===h&&["d"]||h<oc.d&&["dd",h]||1===i&&["M"]||i<oc.M&&["MM",i]||1===j&&["y"]||["yy",j];return k[2]=b,k[3]=+a>0,k[4]=c,hb.apply({},k)}function jb(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=vb(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function kb(a,b,c,d,e){var f,g,h=fb(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:F(a-1)+g}}function lb(b){var c,d=b._i,e=b._f;return b._locale=b._locale||vb.localeData(b._l),null===d||e===a&&""===d?vb.invalid({nullInput:!0}):("string"==typeof d&&(b._i=d=b._locale.preparse(d)),vb.isMoment(d)?new m(d,!0):(e?w(e)?_(b):Y(b):db(b),c=new m(b),c._nextDay&&(c.add(1,"d"),c._nextDay=a),c))}function mb(a,b){var c,d;if(1===b.length&&w(b[0])&&(b=b[0]),!b.length)return vb();for(c=b[0],d=1;d<b.length;++d)b[d][a](c)&&(c=b[d]);return c}function nb(a,b){var c;return"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),D(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function ob(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function pb(a,b,c){return"Month"===b?nb(a,c):a._d["set"+(a._isUTC?"UTC":"")+b](c)}function qb(a,b){return function(c){return null!=c?(pb(this,a,c),vb.updateOffset(this,b),this):ob(this,a)}}function rb(a){return 400*a/146097}function sb(a){return 146097*a/400}function tb(a){vb.duration.fn[a]=function(){return this._data[a]}}function ub(a){"undefined"==typeof ender&&(wb=zb.moment,zb.moment=a?f("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",vb):vb)}for(var vb,wb,xb,yb="2.9.0",zb="undefined"==typeof global||"undefined"!=typeof window&&window!==global.window?this:global,Ab=Math.round,Bb=Object.prototype.hasOwnProperty,Cb=0,Db=1,Eb=2,Fb=3,Gb=4,Hb=5,Ib=6,Jb={},Kb=[],Lb="undefined"!=typeof module&&module&&module.exports,Mb=/^\/?Date\((\-?\d+)/i,Nb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Ob=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Pb=/(\[[^\[]*\])|(\\)?(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,Qb=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Rb=/\d\d?/,Sb=/\d{1,3}/,Tb=/\d{1,4}/,Ub=/[+\-]?\d{1,6}/,Vb=/\d+/,Wb=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Xb=/Z|[\+\-]\d\d:?\d\d/gi,Yb=/T/i,Zb=/[\+\-]?\d+/,$b=/[\+\-]?\d+(\.\d{1,3})?/,_b=/\d/,ac=/\d\d/,bc=/\d{3}/,cc=/\d{4}/,dc=/[+-]?\d{6}/,ec=/[+-]?\d+/,fc=/^\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)?)?$/,gc="YYYY-MM-DDTHH:mm:ssZ",hc=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],ic=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],jc=/([\+\-]|\d\d)/gi,kc=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),lc={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},mc={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},nc={},oc={s:45,m:45,h:22,d:26,M:11},pc="DDD w W M D d".split(" "),qc="M D H h m s w W".split(" "),rc={M:function(){return this.month()+1},MMM:function(a){return this.localeData().monthsShort(this,a)},MMMM:function(a){return this.localeData().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.localeData().weekdaysMin(this,a)},ddd:function(a){return this.localeData().weekdaysShort(this,a)},dddd:function(a){return this.localeData().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return r(this.year()%100,2)},YYYY:function(){return r(this.year(),4)},YYYYY:function(){return r(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+r(Math.abs(a),6)},gg:function(){return r(this.weekYear()%100,2)},gggg:function(){return r(this.weekYear(),4)},ggggg:function(){return r(this.weekYear(),5)},GG:function(){return r(this.isoWeekYear()%100,2)},GGGG:function(){return r(this.isoWeekYear(),4)},GGGGG:function(){return r(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.localeData().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return C(this.milliseconds()/100)},SS:function(){return r(C(this.milliseconds()/10),2)},SSS:function(){return r(this.milliseconds(),3)},SSSS:function(){return r(this.milliseconds(),3)},Z:function(){var a=this.utcOffset(),b="+";return 0>a&&(a=-a,b="-"),b+r(C(a/60),2)+":"+r(C(a)%60,2)},ZZ:function(){var a=this.utcOffset(),b="+";return 0>a&&(a=-a,b="-"),b+r(C(a/60),2)+r(C(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},x:function(){return this.valueOf()},X:function(){return this.unix()},Q:function(){return this.quarter()}},sc={},tc=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"],uc=!1;pc.length;)xb=pc.pop(),rc[xb+"o"]=i(rc[xb],xb);for(;qc.length;)xb=qc.pop(),rc[xb+xb]=h(rc[xb],2);rc.DDDD=h(rc.DDD,3),o(l.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a,b,c){var d,e,f;for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),d=0;12>d;d++){if(e=vb.utc([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=vb([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b,c){var d=this._calendar[a];return"function"==typeof d?d.apply(b,[c]):d},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",_ordinalParse:/\d{1,2}/,preparse:function(a){return a},postformat:function(a){return a},week:function(a){return jb(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},firstDayOfWeek:function(){return this._week.dow},firstDayOfYear:function(){return this._week.doy},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),vb=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=b,g._f=c,g._l=e,g._strict=f,g._isUTC=!1,g._pf=d(),lb(g)},vb.suppressDeprecationWarnings=!1,vb.createFromInputFallback=f("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),vb.min=function(){var a=[].slice.call(arguments,0);return mb("isBefore",a)},vb.max=function(){var a=[].slice.call(arguments,0);return mb("isAfter",a)},vb.utc=function(b,c,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=b,g._f=c,g._strict=f,g._pf=d(),lb(g).utc()},vb.unix=function(a){return vb(1e3*a)},vb.duration=function(a,b){var d,e,f,g,h=a,i=null;return vb.isDuration(a)?h={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(h={},b?h[b]=a:h.milliseconds=a):(i=Nb.exec(a))?(d="-"===i[1]?-1:1,h={y:0,d:C(i[Eb])*d,h:C(i[Fb])*d,m:C(i[Gb])*d,s:C(i[Hb])*d,ms:C(i[Ib])*d}):(i=Ob.exec(a))?(d="-"===i[1]?-1:1,f=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*d},h={y:f(i[2]),M:f(i[3]),d:f(i[4]),h:f(i[5]),m:f(i[6]),s:f(i[7]),w:f(i[8])}):null==h?h={}:"object"==typeof h&&("from"in h||"to"in h)&&(g=t(vb(h.from),vb(h.to)),h={},h.ms=g.milliseconds,h.M=g.months),e=new n(h),vb.isDuration(a)&&c(a,"_locale")&&(e._locale=a._locale),e},vb.version=yb,vb.defaultFormat=gc,vb.ISO_8601=function(){},vb.momentProperties=Kb,vb.updateOffset=function(){},vb.relativeTimeThreshold=function(b,c){return oc[b]===a?!1:c===a?oc[b]:(oc[b]=c,!0)},vb.lang=f("moment.lang is deprecated. Use moment.locale instead.",function(a,b){return vb.locale(a,b)}),vb.locale=function(a,b){var c;return a&&(c="undefined"!=typeof b?vb.defineLocale(a,b):vb.localeData(a),c&&(vb.duration._locale=vb._locale=c)),vb._locale._abbr},vb.defineLocale=function(a,b){return null!==b?(b.abbr=a,Jb[a]||(Jb[a]=new l),Jb[a].set(b),vb.locale(a),Jb[a]):(delete Jb[a],null)},vb.langData=f("moment.langData is deprecated. Use moment.localeData instead.",function(a){return vb.localeData(a)}),vb.localeData=function(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return vb._locale;if(!w(a)){if(b=L(a))return b;a=[a]}return K(a)},vb.isMoment=function(a){return a instanceof m||null!=a&&c(a,"_isAMomentObject")},vb.isDuration=function(a){return a instanceof n};for(xb=tc.length-1;xb>=0;--xb)B(tc[xb]);vb.normalizeUnits=function(a){return z(a)},vb.invalid=function(a){var b=vb.utc(0/0);return null!=a?o(b._pf,a):b._pf.userInvalidated=!0,b},vb.parseZone=function(){return vb.apply(null,arguments).parseZone()},vb.parseTwoDigitYear=function(a){return C(a)+(C(a)>68?1900:2e3)},vb.isDate=x,o(vb.fn=m.prototype,{clone:function(){return vb(this)},valueOf:function(){return+this._d-6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=vb(this).utc();return 0<a.year()&&a.year()<=9999?"function"==typeof Date.prototype.toISOString?this.toDate().toISOString():P(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):P(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds()]},isValid:function(){return I(this)},isDSTShifted:function(){return this._a?this.isValid()&&y(this._a,(this._isUTC?vb.utc(this._a):vb(this._a)).toArray())>0:!1},parsingFlags:function(){return o({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(a){return this.utcOffset(0,a)},local:function(a){return this._isUTC&&(this.utcOffset(0,a),this._isUTC=!1,a&&this.subtract(this._dateUtcOffset(),"m")),this},format:function(a){var b=P(this,a||vb.defaultFormat);return this.localeData().postformat(b)},add:u(1,"add"),subtract:u(-1,"subtract"),diff:function(a,b,c){var d,e,f=M(a,this),g=6e4*(f.utcOffset()-this.utcOffset());return b=z(b),"year"===b||"month"===b||"quarter"===b?(e=j(this,f),"quarter"===b?e/=3:"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:q(e)},from:function(a,b){return vb.duration({to:this,from:a}).locale(this.locale()).humanize(!b)},fromNow:function(a){return this.from(vb(),a)},calendar:function(a){var b=a||vb(),c=M(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.localeData().calendar(e,this,vb(b)))},isLeapYear:function(){return G(this.year())},isDST:function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=gb(a,this.localeData()),this.add(a-b,"d")):b},month:qb("Month",!0),startOf:function(a){switch(a=z(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a?this.weekday(0):"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this},endOf:function(b){return b=z(b),b===a||"millisecond"===b?this:this.startOf(b).add(1,"isoWeek"===b?"week":b).subtract(1,"ms")},isAfter:function(a,b){var c;return b=z("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=vb.isMoment(a)?a:vb(a),+this>+a):(c=vb.isMoment(a)?+a:+vb(a),c<+this.clone().startOf(b))},isBefore:function(a,b){var c;return b=z("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=vb.isMoment(a)?a:vb(a),+a>+this):(c=vb.isMoment(a)?+a:+vb(a),+this.clone().endOf(b)<c)},isBetween:function(a,b,c){return this.isAfter(a,c)&&this.isBefore(b,c)},isSame:function(a,b){var c;return b=z(b||"millisecond"),"millisecond"===b?(a=vb.isMoment(a)?a:vb(a),+this===+a):(c=+vb(a),+this.clone().startOf(b)<=c&&c<=+this.clone().endOf(b))},min:f("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(a){return a=vb.apply(null,arguments),this>a?this:a}),max:f("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(a){return a=vb.apply(null,arguments),a>this?this:a}),zone:f("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",function(a,b){return null!=a?("string"!=typeof a&&(a=-a),this.utcOffset(a,b),this):-this.utcOffset()}),utcOffset:function(a,b){var c,d=this._offset||0;return null!=a?("string"==typeof a&&(a=S(a)),Math.abs(a)<16&&(a=60*a),!this._isUTC&&b&&(c=this._dateUtcOffset()),this._offset=a,this._isUTC=!0,null!=c&&this.add(c,"m"),d!==a&&(!b||this._changeInProgress?v(this,vb.duration(a-d,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,vb.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?d:this._dateUtcOffset()},isLocal:function(){return!this._isUTC},isUtcOffset:function(){return this._isUTC},isUtc:function(){return this._isUTC&&0===this._offset},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(S(this._i)),this},hasAlignedHourOffset:function(a){return a=a?vb(a).utcOffset():0,(this.utcOffset()-a)%60===0},daysInMonth:function(){return D(this.year(),this.month())},dayOfYear:function(a){var b=Ab((vb(this).startOf("day")-vb(this).startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")},quarter:function(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)},weekYear:function(a){var b=jb(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==a?b:this.add(a-b,"y")},isoWeekYear:function(a){var b=jb(this,1,4).year;return null==a?b:this.add(a-b,"y")},week:function(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")},isoWeek:function(a){var b=jb(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")},weekday:function(a){var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return E(this.year(),1,4)},weeksInYear:function(){var a=this.localeData()._week;return E(this.year(),a.dow,a.doy)},get:function(a){return a=z(a),this[a]()},set:function(a,b){var c;if("object"==typeof a)for(c in a)this.set(c,a[c]);else a=z(a),"function"==typeof this[a]&&this[a](b);return this},locale:function(b){var c;return b===a?this._locale._abbr:(c=vb.localeData(b),null!=c&&(this._locale=c),this)},lang:f("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(b){return b===a?this.localeData():this.locale(b)}),localeData:function(){return this._locale},_dateUtcOffset:function(){return 15*-Math.round(this._d.getTimezoneOffset()/15)}}),vb.fn.millisecond=vb.fn.milliseconds=qb("Milliseconds",!1),vb.fn.second=vb.fn.seconds=qb("Seconds",!1),vb.fn.minute=vb.fn.minutes=qb("Minutes",!1),vb.fn.hour=vb.fn.hours=qb("Hours",!0),vb.fn.date=qb("Date",!0),vb.fn.dates=f("dates accessor is deprecated. Use date instead.",qb("Date",!0)),vb.fn.year=qb("FullYear",!0),vb.fn.years=f("years accessor is deprecated. Use year instead.",qb("FullYear",!0)),vb.fn.days=vb.fn.day,vb.fn.months=vb.fn.month,vb.fn.weeks=vb.fn.week,vb.fn.isoWeeks=vb.fn.isoWeek,vb.fn.quarters=vb.fn.quarter,vb.fn.toJSON=vb.fn.toISOString,vb.fn.isUTC=vb.fn.isUtc,o(vb.duration.fn=n.prototype,{_bubble:function(){var a,b,c,d=this._milliseconds,e=this._days,f=this._months,g=this._data,h=0;g.milliseconds=d%1e3,a=q(d/1e3),g.seconds=a%60,b=q(a/60),g.minutes=b%60,c=q(b/60),g.hours=c%24,e+=q(c/24),h=q(rb(e)),e-=q(sb(h)),f+=q(e/30),e%=30,h+=q(f/12),f%=12,g.days=e,g.months=f,g.years=h},abs:function(){return this._milliseconds=Math.abs(this._milliseconds),this._days=Math.abs(this._days),this._months=Math.abs(this._months),this._data.milliseconds=Math.abs(this._data.milliseconds),this._data.seconds=Math.abs(this._data.seconds),this._data.minutes=Math.abs(this._data.minutes),this._data.hours=Math.abs(this._data.hours),this._data.months=Math.abs(this._data.months),this._data.years=Math.abs(this._data.years),this},weeks:function(){return q(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*C(this._months/12) | |
},humanize:function(a){var b=ib(this,!a,this.localeData());return a&&(b=this.localeData().pastFuture(+this,b)),this.localeData().postformat(b)},add:function(a,b){var c=vb.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=vb.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=z(a),this[a.toLowerCase()+"s"]()},as:function(a){var b,c;if(a=z(a),"month"===a||"year"===a)return b=this._days+this._milliseconds/864e5,c=this._months+12*rb(b),"month"===a?c:c/12;switch(b=this._days+Math.round(sb(this._months/12)),a){case"week":return b/7+this._milliseconds/6048e5;case"day":return b+this._milliseconds/864e5;case"hour":return 24*b+this._milliseconds/36e5;case"minute":return 24*b*60+this._milliseconds/6e4;case"second":return 24*b*60*60+this._milliseconds/1e3;case"millisecond":return Math.floor(24*b*60*60*1e3)+this._milliseconds;default:throw new Error("Unknown unit "+a)}},lang:vb.fn.lang,locale:vb.fn.locale,toIsoString:f("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",function(){return this.toISOString()}),toISOString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"},localeData:function(){return this._locale},toJSON:function(){return this.toISOString()}}),vb.duration.fn.toString=vb.duration.fn.toISOString;for(xb in kc)c(kc,xb)&&tb(xb.toLowerCase());vb.duration.fn.asMilliseconds=function(){return this.as("ms")},vb.duration.fn.asSeconds=function(){return this.as("s")},vb.duration.fn.asMinutes=function(){return this.as("m")},vb.duration.fn.asHours=function(){return this.as("h")},vb.duration.fn.asDays=function(){return this.as("d")},vb.duration.fn.asWeeks=function(){return this.as("weeks")},vb.duration.fn.asMonths=function(){return this.as("M")},vb.duration.fn.asYears=function(){return this.as("y")},vb.locale("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===C(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),Lb?module.exports=vb:"function"==typeof define&&define.amd?(define(function(a,b,c){return c.config&&c.config()&&c.config().noGlobal===!0&&(zb.moment=wb),vb}),ub(!0)):ub()}).call(this); | |
filledDate = parseDate('%filltext:name=date%'); | |
momentDate = moment(new Date(filledDate)) | |
momentDate.format('YYYY-MM-DD') | |
%filltop% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment