angular-input-masks
Version:
Personalized input masks for AngularJS
1,594 lines (1,335 loc) • 123 kB
JavaScript
require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = addUTCMinutes;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function addUTCMinutes(dirtyDate, dirtyAmount, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var amount = Number(dirtyAmount);
date.setUTCMinutes(date.getUTCMinutes() + amount);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cloneObject;
function cloneObject(dirtyObject) {
dirtyObject = dirtyObject || {};
var object = {};
for (var property in dirtyObject) {
if (dirtyObject.hasOwnProperty(property)) {
object[property] = dirtyObject[property];
}
}
return object;
}
module.exports = exports["default"];
},{}],3:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getUTCDayOfYear;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MILLISECONDS_IN_DAY = 86400000;
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function getUTCDayOfYear(dirtyDate, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var timestamp = date.getTime();
date.setUTCMonth(0, 1);
date.setUTCHours(0, 0, 0, 0);
var startOfYearTimestamp = date.getTime();
var difference = timestamp - startOfYearTimestamp;
return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31}],4:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getUTCISOWeek;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../startOfUTCISOWeek/index.js');
var _index4 = _interopRequireDefault(_index3);
var _index5 = require('../startOfUTCISOWeekYear/index.js');
var _index6 = _interopRequireDefault(_index5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MILLISECONDS_IN_WEEK = 604800000;
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function getUTCISOWeek(dirtyDate, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var diff = (0, _index4.default)(date, dirtyOptions).getTime() - (0, _index6.default)(date, dirtyOptions).getTime();
// Round the number of days to the nearest integer
// because the number of milliseconds in a week is not constant
// (e.g. it's different in the week of the daylight saving time clock shift)
return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31,"../startOfUTCISOWeek/index.js":10,"../startOfUTCISOWeekYear/index.js":11}],5:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getUTCISOWeekYear;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../startOfUTCISOWeek/index.js');
var _index4 = _interopRequireDefault(_index3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function getUTCISOWeekYear(dirtyDate, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var year = date.getUTCFullYear();
var fourthOfJanuaryOfNextYear = new Date(0);
fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
var startOfNextYear = (0, _index4.default)(fourthOfJanuaryOfNextYear, dirtyOptions);
var fourthOfJanuaryOfThisYear = new Date(0);
fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
var startOfThisYear = (0, _index4.default)(fourthOfJanuaryOfThisYear, dirtyOptions);
if (date.getTime() >= startOfNextYear.getTime()) {
return year + 1;
} else if (date.getTime() >= startOfThisYear.getTime()) {
return year;
} else {
return year - 1;
}
}
module.exports = exports['default'];
},{"../../toDate/index.js":31,"../startOfUTCISOWeek/index.js":10}],6:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = setUTCDay;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function setUTCDay(dirtyDate, dirtyDay, dirtyOptions) {
var options = dirtyOptions || {};
var locale = options.locale;
var localeWeekStartsOn = locale && locale.options && locale.options.weekStartsOn;
var defaultWeekStartsOn = localeWeekStartsOn === undefined ? 0 : Number(localeWeekStartsOn);
var weekStartsOn = options.weekStartsOn === undefined ? defaultWeekStartsOn : Number(options.weekStartsOn);
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
}
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var day = Number(dirtyDay);
var currentDay = date.getUTCDay();
var remainder = day % 7;
var dayIndex = (remainder + 7) % 7;
var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
date.setUTCDate(date.getUTCDate() + diff);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31}],7:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = setUTCISODay;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function setUTCISODay(dirtyDate, dirtyDay, dirtyOptions) {
var day = Number(dirtyDay);
if (day % 7 === 0) {
day = day - 7;
}
var weekStartsOn = 1;
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var currentDay = date.getUTCDay();
var remainder = day % 7;
var dayIndex = (remainder + 7) % 7;
var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
date.setUTCDate(date.getUTCDate() + diff);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31}],8:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = setUTCISOWeek;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../getUTCISOWeek/index.js');
var _index4 = _interopRequireDefault(_index3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function setUTCISOWeek(dirtyDate, dirtyISOWeek, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var isoWeek = Number(dirtyISOWeek);
var diff = (0, _index4.default)(date, dirtyOptions) - isoWeek;
date.setUTCDate(date.getUTCDate() - diff * 7);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31,"../getUTCISOWeek/index.js":4}],9:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = setUTCISOWeekYear;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../startOfUTCISOWeekYear/index.js');
var _index4 = _interopRequireDefault(_index3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MILLISECONDS_IN_DAY = 86400000;
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function setUTCISOWeekYear(dirtyDate, dirtyISOYear, dirtyOptions) {
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var isoYear = Number(dirtyISOYear);
var dateStartOfYear = (0, _index4.default)(date, dirtyOptions);
var diff = Math.floor((date.getTime() - dateStartOfYear.getTime()) / MILLISECONDS_IN_DAY);
var fourthOfJanuary = new Date(0);
fourthOfJanuary.setUTCFullYear(isoYear, 0, 4);
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
date = (0, _index4.default)(fourthOfJanuary, dirtyOptions);
date.setUTCDate(date.getUTCDate() + diff);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31,"../startOfUTCISOWeekYear/index.js":11}],10:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = startOfUTCISOWeek;
var _index = require('../../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function startOfUTCISOWeek(dirtyDate, dirtyOptions) {
var weekStartsOn = 1;
var date = (0, _index2.default)(dirtyDate, dirtyOptions);
var day = date.getUTCDay();
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
date.setUTCDate(date.getUTCDate() - diff);
date.setUTCHours(0, 0, 0, 0);
return date;
}
module.exports = exports['default'];
},{"../../toDate/index.js":31}],11:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = startOfUTCISOWeekYear;
var _index = require('../getUTCISOWeekYear/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../startOfUTCISOWeek/index.js');
var _index4 = _interopRequireDefault(_index3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This function will be a part of public API when UTC function will be implemented.
// See issue: https://github.com/date-fns/date-fns/issues/376
function startOfUTCISOWeekYear(dirtyDate, dirtyOptions) {
var year = (0, _index2.default)(dirtyDate, dirtyOptions);
var fourthOfJanuary = new Date(0);
fourthOfJanuary.setUTCFullYear(year, 0, 4);
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
var date = (0, _index4.default)(fourthOfJanuary, dirtyOptions);
return date;
}
module.exports = exports['default'];
},{"../getUTCISOWeekYear/index.js":5,"../startOfUTCISOWeek/index.js":10}],12:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = addMilliseconds;
var _index = require('../toDate/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @name addMilliseconds
* @category Millisecond Helpers
* @summary Add the specified number of milliseconds to the given date.
*
* @description
* Add the specified number of milliseconds to the given date.
*
* @param {Date|String|Number} date - the date to be changed
* @param {Number} amount - the amount of milliseconds to be added
* @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
* @returns {Date} the new date with the milliseconds added
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
* var result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
* //=> Thu Jul 10 2014 12:45:30.750
*/
function addMilliseconds(dirtyDate, dirtyAmount, dirtyOptions) {
if (arguments.length < 2) {
throw new TypeError('2 arguments required, but only ' + arguments.length + ' present');
}
var timestamp = (0, _index2.default)(dirtyDate, dirtyOptions).getTime();
var amount = Number(dirtyAmount);
return new Date(timestamp + amount);
}
module.exports = exports['default'];
},{"../toDate/index.js":31}],13:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = addMinutes;
var _index = require('../addMilliseconds/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MILLISECONDS_IN_MINUTE = 60000;
/**
* @name addMinutes
* @category Minute Helpers
* @summary Add the specified number of minutes to the given date.
*
* @description
* Add the specified number of minutes to the given date.
*
* @param {Date|String|Number} date - the date to be changed
* @param {Number} amount - the amount of minutes to be added
* @param {Options} [options] - the object with options. See [Options]{@link https://date-fns.org/docs/Options}
* @param {0|1|2} [options.additionalDigits=2] - passed to `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
* @returns {Date} the new date with the minutes added
* @throws {TypeError} 2 arguments required
* @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
*
* @example
* // Add 30 minutes to 10 July 2014 12:00:00:
* var result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
* //=> Thu Jul 10 2014 12:30:00
*/
function addMinutes(dirtyDate, dirtyAmount, dirtyOptions) {
if (arguments.length < 2) {
throw new TypeError('2 arguments required, but only ' + arguments.length + ' present');
}
var amount = Number(dirtyAmount);
return (0, _index2.default)(dirtyDate, amount * MILLISECONDS_IN_MINUTE, dirtyOptions);
}
module.exports = exports['default'];
},{"../addMilliseconds/index.js":12}],14:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require('../../../_lib/getUTCDayOfYear/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../../../_lib/getUTCISOWeek/index.js');
var _index4 = _interopRequireDefault(_index3);
var _index5 = require('../../../_lib/getUTCISOWeekYear/index.js');
var _index6 = _interopRequireDefault(_index5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var formatters = {
// Month: 1, 2, ..., 12
'M': function M(date) {
return date.getUTCMonth() + 1;
},
// Month: 1st, 2nd, ..., 12th
'Mo': function Mo(date, options) {
var month = date.getUTCMonth() + 1;
return options.locale.localize.ordinalNumber(month, { unit: 'month' });
},
// Month: 01, 02, ..., 12
'MM': function MM(date) {
return addLeadingZeros(date.getUTCMonth() + 1, 2);
},
// Month: Jan, Feb, ..., Dec
'MMM': function MMM(date, options) {
return options.locale.localize.month(date.getUTCMonth(), { type: 'short' });
},
// Month: January, February, ..., December
'MMMM': function MMMM(date, options) {
return options.locale.localize.month(date.getUTCMonth(), { type: 'long' });
},
// Quarter: 1, 2, 3, 4
'Q': function Q(date) {
return Math.ceil((date.getUTCMonth() + 1) / 3);
},
// Quarter: 1st, 2nd, 3rd, 4th
'Qo': function Qo(date, options) {
var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
return options.locale.localize.ordinalNumber(quarter, { unit: 'quarter' });
},
// Day of month: 1, 2, ..., 31
'D': function D(date) {
return date.getUTCDate();
},
// Day of month: 1st, 2nd, ..., 31st
'Do': function Do(date, options) {
return options.locale.localize.ordinalNumber(date.getUTCDate(), { unit: 'dayOfMonth' });
},
// Day of month: 01, 02, ..., 31
'DD': function DD(date) {
return addLeadingZeros(date.getUTCDate(), 2);
},
// Day of year: 1, 2, ..., 366
'DDD': function DDD(date) {
return (0, _index2.default)(date);
},
// Day of year: 1st, 2nd, ..., 366th
'DDDo': function DDDo(date, options) {
return options.locale.localize.ordinalNumber((0, _index2.default)(date), { unit: 'dayOfYear' });
},
// Day of year: 001, 002, ..., 366
'DDDD': function DDDD(date) {
return addLeadingZeros((0, _index2.default)(date), 3);
},
// Day of week: Su, Mo, ..., Sa
'dd': function dd(date, options) {
return options.locale.localize.weekday(date.getUTCDay(), { type: 'narrow' });
},
// Day of week: Sun, Mon, ..., Sat
'ddd': function ddd(date, options) {
return options.locale.localize.weekday(date.getUTCDay(), { type: 'short' });
},
// Day of week: Sunday, Monday, ..., Saturday
'dddd': function dddd(date, options) {
return options.locale.localize.weekday(date.getUTCDay(), { type: 'long' });
},
// Day of week: 0, 1, ..., 6
'd': function d(date) {
return date.getUTCDay();
},
// Day of week: 0th, 1st, 2nd, ..., 6th
'do': function _do(date, options) {
return options.locale.localize.ordinalNumber(date.getUTCDay(), { unit: 'dayOfWeek' });
},
// Day of ISO week: 1, 2, ..., 7
'E': function E(date) {
return date.getUTCDay() || 7;
},
// ISO week: 1, 2, ..., 53
'W': function W(date) {
return (0, _index4.default)(date);
},
// ISO week: 1st, 2nd, ..., 53th
'Wo': function Wo(date, options) {
return options.locale.localize.ordinalNumber((0, _index4.default)(date), { unit: 'isoWeek' });
},
// ISO week: 01, 02, ..., 53
'WW': function WW(date) {
return addLeadingZeros((0, _index4.default)(date), 2);
},
// Year: 00, 01, ..., 99
'YY': function YY(date) {
return addLeadingZeros(date.getUTCFullYear(), 4).substr(2);
},
// Year: 1900, 1901, ..., 2099
'YYYY': function YYYY(date) {
return addLeadingZeros(date.getUTCFullYear(), 4);
},
// ISO week-numbering year: 00, 01, ..., 99
'GG': function GG(date) {
return String((0, _index6.default)(date)).substr(2);
},
// ISO week-numbering year: 1900, 1901, ..., 2099
'GGGG': function GGGG(date) {
return (0, _index6.default)(date);
},
// Hour: 0, 1, ... 23
'H': function H(date) {
return date.getUTCHours();
},
// Hour: 00, 01, ..., 23
'HH': function HH(date) {
return addLeadingZeros(date.getUTCHours(), 2);
},
// Hour: 1, 2, ..., 12
'h': function h(date) {
var hours = date.getUTCHours();
if (hours === 0) {
return 12;
} else if (hours > 12) {
return hours % 12;
} else {
return hours;
}
},
// Hour: 01, 02, ..., 12
'hh': function hh(date) {
return addLeadingZeros(formatters['h'](date), 2);
},
// Minute: 0, 1, ..., 59
'm': function m(date) {
return date.getUTCMinutes();
},
// Minute: 00, 01, ..., 59
'mm': function mm(date) {
return addLeadingZeros(date.getUTCMinutes(), 2);
},
// Second: 0, 1, ..., 59
's': function s(date) {
return date.getUTCSeconds();
},
// Second: 00, 01, ..., 59
'ss': function ss(date) {
return addLeadingZeros(date.getUTCSeconds(), 2);
},
// 1/10 of second: 0, 1, ..., 9
'S': function S(date) {
return Math.floor(date.getUTCMilliseconds() / 100);
},
// 1/100 of second: 00, 01, ..., 99
'SS': function SS(date) {
return addLeadingZeros(Math.floor(date.getUTCMilliseconds() / 10), 2);
},
// Millisecond: 000, 001, ..., 999
'SSS': function SSS(date) {
return addLeadingZeros(date.getUTCMilliseconds(), 3);
},
// Timezone: -01:00, +00:00, ... +12:00
'Z': function Z(date, options) {
var originalDate = options._originalDate || date;
return formatTimezone(originalDate.getTimezoneOffset(), ':');
},
// Timezone: -0100, +0000, ... +1200
'ZZ': function ZZ(date, options) {
var originalDate = options._originalDate || date;
return formatTimezone(originalDate.getTimezoneOffset());
},
// Seconds timestamp: 512969520
'X': function X(date, options) {
var originalDate = options._originalDate || date;
return Math.floor(originalDate.getTime() / 1000);
},
// Milliseconds timestamp: 512969520900
'x': function x(date, options) {
var originalDate = options._originalDate || date;
return originalDate.getTime();
},
// AM, PM
'A': function A(date, options) {
return options.locale.localize.timeOfDay(date.getUTCHours(), { type: 'uppercase' });
},
// am, pm
'a': function a(date, options) {
return options.locale.localize.timeOfDay(date.getUTCHours(), { type: 'lowercase' });
},
// a.m., p.m.
'aa': function aa(date, options) {
return options.locale.localize.timeOfDay(date.getUTCHours(), { type: 'long' });
}
};
function formatTimezone(offset, delimeter) {
delimeter = delimeter || '';
var sign = offset > 0 ? '-' : '+';
var absOffset = Math.abs(offset);
var hours = Math.floor(absOffset / 60);
var minutes = absOffset % 60;
return sign + addLeadingZeros(hours, 2) + delimeter + addLeadingZeros(minutes, 2);
}
function addLeadingZeros(number, targetLength) {
var output = Math.abs(number).toString();
while (output.length < targetLength) {
output = '0' + output;
}
return output;
}
exports.default = formatters;
module.exports = exports['default'];
},{"../../../_lib/getUTCDayOfYear/index.js":3,"../../../_lib/getUTCISOWeek/index.js":4,"../../../_lib/getUTCISOWeekYear/index.js":5}],15:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildFormatLongFn;
var tokensToBeShortedPattern = /MMMM|MM|DD|dddd/g;
function buildShortLongFormat(format) {
return format.replace(tokensToBeShortedPattern, function (token) {
return token.slice(1);
});
}
/**
* @name buildFormatLongFn
* @category Locale Helpers
* @summary Build `formatLong` property for locale used by `format`, `formatRelative` and `parse` functions.
*
* @description
* Build `formatLong` property for locale used by `format`, `formatRelative` and `parse` functions.
* Returns a function which takes one of the following tokens as the argument:
* `'LTS'`, `'LT'`, `'L'`, `'LL'`, `'LLL'`, `'l'`, `'ll'`, `'lll'`, `'llll'`
* and returns a long format string written as `format` token strings.
* See [format]{@link https://date-fns.org/docs/format}
*
* `'l'`, `'ll'`, `'lll'` and `'llll'` formats are built automatically
* by shortening some of the tokens from corresponding unshortened formats
* (e.g., if `LL` is `'MMMM DD YYYY'` then `ll` will be `MMM D YYYY`)
*
* @param {Object} obj - the object with long formats written as `format` token strings
* @param {String} obj.LT - time format: hours and minutes
* @param {String} obj.LTS - time format: hours, minutes and seconds
* @param {String} obj.L - short date format: numeric day, month and year
* @param {String} [obj.l] - short date format: numeric day, month and year (shortened)
* @param {String} obj.LL - long date format: day, month in words, and year
* @param {String} [obj.ll] - long date format: day, month in words, and year (shortened)
* @param {String} obj.LLL - long date and time format
* @param {String} [obj.lll] - long date and time format (shortened)
* @param {String} obj.LLLL - long date, time and weekday format
* @param {String} [obj.llll] - long date, time and weekday format (shortened)
* @returns {Function} `formatLong` property of the locale
*
* @example
* // For `en-US` locale:
* locale.formatLong = buildFormatLongFn({
* LT: 'h:mm aa',
* LTS: 'h:mm:ss aa',
* L: 'MM/DD/YYYY',
* LL: 'MMMM D YYYY',
* LLL: 'MMMM D YYYY h:mm aa',
* LLLL: 'dddd, MMMM D YYYY h:mm aa'
* })
*/
function buildFormatLongFn(obj) {
var formatLongLocale = {
LTS: obj.LTS,
LT: obj.LT,
L: obj.L,
LL: obj.LL,
LLL: obj.LLL,
LLLL: obj.LLLL,
l: obj.l || buildShortLongFormat(obj.L),
ll: obj.ll || buildShortLongFormat(obj.LL),
lll: obj.lll || buildShortLongFormat(obj.LLL),
llll: obj.llll || buildShortLongFormat(obj.LLLL)
};
return function (token) {
return formatLongLocale[token];
};
}
module.exports = exports["default"];
},{}],16:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildLocalizeArrayFn;
/**
* @name buildLocalizeArrayFn
* @category Locale Helpers
* @summary Build `localize.weekdays`, `localize.months` and `localize.timesOfDay` properties for the locale.
*
* @description
* Build `localize.weekdays`, `localize.months` and `localize.timesOfDay` properties for the locale.
* If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example).
*
* @param {Object} values - the object with arrays of values
* @param {String} defaultType - the default type for the localize function
* @returns {Function} the resulting function
*
* @example
* var weekdayValues = {
* narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
* short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
* long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
* }
* locale.localize.weekdays = buildLocalizeArrayFn(weekdayValues, 'long')
* locale.localize.weekdays({type: 'narrow'}) //=> ['Su', 'Mo', ...]
* locale.localize.weekdays() //=> ['Sunday', 'Monday', ...]
*/
function buildLocalizeArrayFn(values, defaultType) {
return function (dirtyOptions) {
var options = dirtyOptions || {};
var type = options.type ? String(options.type) : defaultType;
return values[type] || values[defaultType];
};
}
module.exports = exports["default"];
},{}],17:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildLocalizeFn;
/**
* @name buildLocalizeFn
* @category Locale Helpers
* @summary Build `localize.weekday`, `localize.month` and `localize.timeOfDay` properties for the locale.
*
* @description
* Build `localize.weekday`, `localize.month` and `localize.timeOfDay` properties for the locale
* used by `format` function.
* If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example).
*
* `localize.weekday` function takes the weekday index as argument (0 - Sunday).
* `localize.month` takes the month index (0 - January).
* `localize.timeOfDay` takes the hours. Use `indexCallback` to convert them to an array index (see example).
*
* @param {Object} values - the object with arrays of values
* @param {String} defaultType - the default type for the localize function
* @param {Function} [indexCallback] - the callback which takes the resulting function argument
* and converts it into value array index
* @returns {Function} the resulting function
*
* @example
* var timeOfDayValues = {
* uppercase: ['AM', 'PM'],
* lowercase: ['am', 'pm'],
* long: ['a.m.', 'p.m.']
* }
* locale.localize.timeOfDay = buildLocalizeFn(timeOfDayValues, 'long', function (hours) {
* // 0 is a.m. array index, 1 is p.m. array index
* return (hours / 12) >= 1 ? 1 : 0
* })
* locale.localize.timeOfDay(16, {type: 'uppercase'}) //=> 'PM'
* locale.localize.timeOfDay(5) //=> 'a.m.'
*/
function buildLocalizeFn(values, defaultType, indexCallback) {
return function (dirtyIndex, dirtyOptions) {
var options = dirtyOptions || {};
var type = options.type ? String(options.type) : defaultType;
var valuesArray = values[type] || values[defaultType];
var index = indexCallback ? indexCallback(Number(dirtyIndex)) : Number(dirtyIndex);
return valuesArray[index];
};
}
module.exports = exports["default"];
},{}],18:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildMatchFn;
/**
* @name buildMatchFn
* @category Locale Helpers
* @summary Build `match.weekdays`, `match.months` and `match.timesOfDay` properties for the locale.
*
* @description
* Build `match.weekdays`, `match.months` and `match.timesOfDay` properties for the locale used by `parse` function.
* If no `type` is supplied to the options of the resulting function, `defaultType` will be used (see example).
* The result of the match function will be passed into corresponding parser function
* (`match.weekday`, `match.month` or `match.timeOfDay` respectively. See `buildParseFn`).
*
* @param {Object} values - the object with RegExps
* @param {String} defaultType - the default type for the match function
* @returns {Function} the resulting function
*
* @example
* var matchWeekdaysPatterns = {
* narrow: /^(su|mo|tu|we|th|fr|sa)/i,
* short: /^(sun|mon|tue|wed|thu|fri|sat)/i,
* long: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
* }
* locale.match.weekdays = buildMatchFn(matchWeekdaysPatterns, 'long')
* locale.match.weekdays('Sunday', {type: 'narrow'}) //=> ['Su', 'Su', ...]
* locale.match.weekdays('Sunday') //=> ['Sunday', 'Sunday', ...]
*/
function buildMatchFn(patterns, defaultType) {
return function (dirtyString, dirtyOptions) {
var options = dirtyOptions || {};
var type = options.type ? String(options.type) : defaultType;
var pattern = patterns[type] || patterns[defaultType];
var string = String(dirtyString);
return string.match(pattern);
};
}
module.exports = exports["default"];
},{}],19:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildMatchPatternFn;
/**
* @name buildMatchPatternFn
* @category Locale Helpers
* @summary Build match function from a single RegExp.
*
* @description
* Build match function from a single RegExp.
* Usually used for building `match.ordinalNumbers` property of the locale.
*
* @param {Object} pattern - the RegExp
* @returns {Function} the resulting function
*
* @example
* locale.match.ordinalNumbers = buildMatchPatternFn(/^(\d+)(th|st|nd|rd)?/i)
* locale.match.ordinalNumbers('3rd') //=> ['3rd', '3', 'rd', ...]
*/
function buildMatchPatternFn(pattern) {
return function (dirtyString) {
var string = String(dirtyString);
return string.match(pattern);
};
}
module.exports = exports["default"];
},{}],20:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildParseFn;
/**
* @name buildParseFn
* @category Locale Helpers
* @summary Build `match.weekday`, `match.month` and `match.timeOfDay` properties for the locale.
*
* @description
* Build `match.weekday`, `match.month` and `match.timeOfDay` properties for the locale used by `parse` function.
* The argument of the resulting function is the result of the corresponding match function
* (`match.weekdays`, `match.months` or `match.timesOfDay` respectively. See `buildMatchFn`).
*
* @param {Object} values - the object with arrays of RegExps
* @param {String} defaultType - the default type for the parser function
* @returns {Function} the resulting function
*
* @example
* var parseWeekdayPatterns = {
* any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
* }
* locale.match.weekday = buildParseFn(matchWeekdaysPatterns, 'long')
* var matchResult = locale.match.weekdays('Friday')
* locale.match.weekday(matchResult) //=> 5
*/
function buildParseFn(patterns, defaultType) {
return function (matchResult, dirtyOptions) {
var options = dirtyOptions || {};
var type = options.type ? String(options.type) : defaultType;
var patternsArray = patterns[type] || patterns[defaultType];
var string = matchResult[1];
return patternsArray.findIndex(function (pattern) {
return pattern.test(string);
});
};
}
module.exports = exports["default"];
},{}],21:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = parseDecimal;
/**
* @name parseDecimal
* @category Locale Helpers
* @summary Parses the match result into decimal number.
*
* @description
* Parses the match result into decimal number.
* Uses the string matched with the first set of parentheses of match RegExp.
*
* @param {Array} matchResult - the object returned by matching function
* @returns {Number} the parsed value
*
* @example
* locale.match = {
* ordinalNumbers: (dirtyString) {
* return String(dirtyString).match(/^(\d+)(th|st|nd|rd)?/i)
* },
* ordinalNumber: parseDecimal
* }
*/
function parseDecimal(matchResult) {
return parseInt(matchResult[1], 10);
}
module.exports = exports["default"];
},{}],22:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = formatDistance;
var formatDistanceLocale = {
lessThanXSeconds: {
one: 'less than a second',
other: 'less than {{count}} seconds'
},
xSeconds: {
one: '1 second',
other: '{{count}} seconds'
},
halfAMinute: 'half a minute',
lessThanXMinutes: {
one: 'less than a minute',
other: 'less than {{count}} minutes'
},
xMinutes: {
one: '1 minute',
other: '{{count}} minutes'
},
aboutXHours: {
one: 'about 1 hour',
other: 'about {{count}} hours'
},
xHours: {
one: '1 hour',
other: '{{count}} hours'
},
xDays: {
one: '1 day',
other: '{{count}} days'
},
aboutXMonths: {
one: 'about 1 month',
other: 'about {{count}} months'
},
xMonths: {
one: '1 month',
other: '{{count}} months'
},
aboutXYears: {
one: 'about 1 year',
other: 'about {{count}} years'
},
xYears: {
one: '1 year',
other: '{{count}} years'
},
overXYears: {
one: 'over 1 year',
other: 'over {{count}} years'
},
almostXYears: {
one: 'almost 1 year',
other: 'almost {{count}} years'
}
};
function formatDistance(token, count, options) {
options = options || {};
var result;
if (typeof formatDistanceLocale[token] === 'string') {
result = formatDistanceLocale[token];
} else if (count === 1) {
result = formatDistanceLocale[token].one;
} else {
result = formatDistanceLocale[token].other.replace('{{count}}', count);
}
if (options.addSuffix) {
if (options.comparison > 0) {
return 'in ' + result;
} else {
return result + ' ago';
}
}
return result;
}
module.exports = exports['default'];
},{}],23:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require('../../../_lib/buildFormatLongFn/index.js');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var formatLong = (0, _index2.default)({
LT: 'h:mm aa',
LTS: 'h:mm:ss aa',
L: 'MM/DD/YYYY',
LL: 'MMMM D YYYY',
LLL: 'MMMM D YYYY h:mm aa',
LLLL: 'dddd, MMMM D YYYY h:mm aa'
});
exports.default = formatLong;
module.exports = exports['default'];
},{"../../../_lib/buildFormatLongFn/index.js":15}],24:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = formatRelative;
var formatRelativeLocale = {
lastWeek: '[last] dddd [at] LT',
yesterday: '[yesterday at] LT',
today: '[today at] LT',
tomorrow: '[tomorrow at] LT',
nextWeek: 'dddd [at] LT',
other: 'L'
};
function formatRelative(token, date, baseDate, options) {
return formatRelativeLocale[token];
}
module.exports = exports['default'];
},{}],25:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require('../../../_lib/buildLocalizeFn/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../../../_lib/buildLocalizeArrayFn/index.js');
var _index4 = _interopRequireDefault(_index3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Note: in English, the names of days of the week and months are capitalized.
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
// Generally, formatted dates should look like they are in the middle of a sentence,
// e.g. in Spanish language the weekdays and months should be in the lowercase.
var weekdayValues = {
narrow: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
short: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
};
var monthValues = {
short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
long: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
};
// `timeOfDay` is used to designate which part of the day it is, when used with 12-hour clock.
// Use the system which is used the most commonly in the locale.
// For example, if the country doesn't use a.m./p.m., you can use `night`/`morning`/`afternoon`/`evening`:
//
// var timeOfDayValues = {
// any: ['in the night', 'in the morning', 'in the afternoon', 'in the evening']
// }
//
// And later:
//
// var localize = {
// // The callback takes the hours as the argument and returns the array index
// timeOfDay: buildLocalizeFn(timeOfDayValues, 'any', function (hours) {
// if (hours >= 17) {
// return 3
// } else if (hours >= 12) {
// return 2
// } else if (hours >= 4) {
// return 1
// } else {
// return 0
// }
// }),
// timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'any')
// }
var timeOfDayValues = {
uppercase: ['AM', 'PM'],
lowercase: ['am', 'pm'],
long: ['a.m.', 'p.m.']
};
function ordinalNumber(dirtyNumber, dirtyOptions) {
var number = Number(dirtyNumber);
// If ordinal numbers depend on context, for example,
// if they are different for different grammatical genders,
// use `options.unit`:
//
// var options = dirtyOptions || {}
// var unit = String(options.unit)
//
// where `unit` can be 'month', 'quarter', 'week', 'isoWeek', 'dayOfYear',
// 'dayOfMonth' or 'dayOfWeek'
var rem100 = number % 100;
if (rem100 > 20 || rem100 < 10) {
switch (rem100 % 10) {
case 1:
return number + 'st';
case 2:
return number + 'nd';
case 3:
return number + 'rd';
}
}
return number + 'th';
}
var localize = {
ordinalNumber: ordinalNumber,
weekday: (0, _index2.default)(weekdayValues, 'long'),
weekdays: (0, _index4.default)(weekdayValues, 'long'),
month: (0, _index2.default)(monthValues, 'long'),
months: (0, _index4.default)(monthValues, 'long'),
timeOfDay: (0, _index2.default)(timeOfDayValues, 'long', function (hours) {
return hours / 12 >= 1 ? 1 : 0;
}),
timesOfDay: (0, _index4.default)(timeOfDayValues, 'long')
};
exports.default = localize;
module.exports = exports['default'];
},{"../../../_lib/buildLocalizeArrayFn/index.js":16,"../../../_lib/buildLocalizeFn/index.js":17}],26:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require('../../../_lib/buildMatchFn/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('../../../_lib/buildParseFn/index.js');
var _index4 = _interopRequireDefault(_index3);
var _index5 = require('../../../_lib/buildMatchPatternFn/index.js');
var _index6 = _interopRequireDefault(_index5);
var _index7 = require('../../../_lib/parseDecimal/index.js');
var _index8 = _interopRequireDefault(_index7);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var matchOrdinalNumbersPattern = /^(\d+)(th|st|nd|rd)?/i;
var matchWeekdaysPatterns = {
narrow: /^(su|mo|tu|we|th|fr|sa)/i,
short: /^(sun|mon|tue|wed|thu|fri|sat)/i,
long: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
};
var parseWeekdayPatterns = {
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
};
var matchMonthsPatterns = {
short: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
long: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
};
var parseMonthPatterns = {
any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
};
// `timeOfDay` is used to designate which part of the day it is, when used with 12-hour clock.
// Use the system which is used the most commonly in the locale.
// For example, if the country doesn't use a.m./p.m., you can use `night`/`morning`/`afternoon`/`evening`:
//
// var matchTimesOfDayPatterns = {
// long: /^((in the)? (night|morning|afternoon|evening?))/i
// }
//
// var parseTimeOfDayPatterns = {
// any: [/(night|morning)/i, /(afternoon|evening)/i]
// }
var matchTimesOfDayPatterns = {
short: /^(am|pm)/i,
long: /^([ap]\.?\s?m\.?)/i
};
var parseTimeOfDayPatterns = {
any: [/^a/i, /^p/i]
};
var match = {
ordinalNumbers: (0, _index6.default)(matchOrdinalNumbersPattern),
ordinalNumber: _index8.default,
weekdays: (0, _index2.default)(matchWeekdaysPatterns, 'long'),
weekday: (0, _index4.default)(parseWeekdayPatterns, 'any'),
months: (0, _index2.default)(matchMonthsPatterns, 'long'),
month: (0, _index4.default)(parseMonthPatterns, 'any'),
timesOfDay: (0, _index2.default)(matchTimesOfDayPatterns, 'long'),
timeOfDay: (0, _index4.default)(parseTimeOfDayPatterns, 'any')
};
exports.default = match;
module.exports = exports['default'];
},{"../../../_lib/buildMatchFn/index.js":18,"../../../_lib/buildMatchPatternFn/index.js":19,"../../../_lib/buildParseFn/index.js":20,"../../../_lib/parseDecimal/index.js":21}],27:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _index = require('./_lib/formatDistance/index.js');
var _index2 = _interopRequireDefault(_index);
var _index3 = require('./_lib/formatLong/index.js');
var _index4 = _interopRequireDefault(_index3);
var _index5 = require('./_lib/formatRelative/index.js');
var _index6 = _interopRequireDefault(_index5);
var _index7 = require('./_lib/localize/index.js');
var _index8 = _interopRequireDefault(_index7);
var _index9 = require('./_lib/match/index.js');
var _index10 = _interopRequireDefault(_index9);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @type {Locale}
* @category Locales
* @summary English locale (United States).
* @language English
* @iso-639-2 eng
*/
var locale = {
formatDistance: _index2.default,
formatLong: _index4.default,
formatRelative: _index6.default,
localize: _index8.default,
match: _index10.default,
options: {
weekStartsOn: 0 /* Sunday */
, firstWeekContainsDate: 1
}
};
exports.default = locale;
module.exports = exports['default'];
},{"./_lib/formatDistance/index.js":22,"./_lib/formatLong/index.js":23,"./_lib/formatRelative/index.js":24,"./_lib/localize/index.js":25,"./_lib/match/index.js":26}],28:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var patterns = {
'M': /^(1[0-2]|0?\d)/, // 0 to 12
'D': /^(3[0-1]|[0-2]?\d)/, // 0 to 31
'DDD': /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, // 0 to 366
'W': /^(5[0-3]|[0-4]?\d)/, // 0 to 53
'YYYY': /^(\d{1,4})/, // 0 to 9999
'H': /^(2[0-3]|[0-1]?\d)/, // 0 to 23
'm': /^([0-5]?\d)/, // 0 to 59
'Z': /^([+-])(\d{2}):(\d{2})/,
'ZZ': /^([+-])(\d{2})(\d{2})/,
singleDigit: /^(\d)/,
twoDigits: /^(\d{2})/,
threeDigits: /^(\d{3})/,
fourDigits: /^(\d{4})/,
anyDigits: /^(\d+)/
};
function parseDecimal(matchResult) {
return parseInt(matchResult[1], 10);
}
var parsers = {
// Year: 00, 01, ..., 99
'YY': {
unit: 'twoDigitYear',
match: patterns.twoDigits,
parse: function parse(matchResult) {
return parseDecimal(matchResult);
}
},
// Year: 1900, 1901, ..., 2099
'YYYY': {
unit: 'year',
match: patterns.YYYY,
parse: parseDecimal
},
// ISO week-numbering year: 00, 01, ..., 99
'GG': {
unit: 'isoYear',
match: patterns.twoDigits,
parse: function parse(matchResult) {
return parseDecimal(matchResult) + 1900;
}
},
// ISO week-numbering year: 1900, 1901, ..., 2099
'GGGG': {
unit: 'isoYear',
match: patterns.YYYY,
parse: parseDecimal
},
// Quarter: 1, 2, 3, 4
'Q': {
unit: 'quarter',
match: patterns.singleDigit,
parse: parseDecimal
},
// Ordinal quarter
'Qo': {
unit: 'quarter',
match: function match(string, options) {
return options.locale.match.ordinalNumbers(string, { unit: 'quarter' });
},
parse: function parse(matchResult, options) {
return options.locale.match.ordinalNumber(matchResult, { unit: 'quarter' });
}
},
// Month: 1, 2, ..., 12
'M': {
unit: 'month',
match: patterns.M,
parse: function parse(matchResult) {
return parseDecimal(matchResult) - 1;
}
},
// Ordinal month
'Mo': {
unit: 'month',
match: function match(string, options) {
return options.locale.match.ordinalNumbers(string, { unit: 'month' });
},
parse: function parse(matchResult, options) {
return options.locale.match.ordinalNumber(matchResult, { unit: 'month' }) - 1;
}
},
// Month: 01, 02, ..., 12
'MM': {
unit: 'month',
match: patterns.twoDigits,
parse: function parse(matchResult) {
return parseDecimal(matchResult) - 1;
}
},
// Month: Jan, Feb, ..., Dec
'MMM': {
unit: 'month',
match: function match(string, options) {
return options.locale.match.months(string, { type: 'short' });
},
parse: function parse(matchResult, options) {
return options.locale.match.month(matchResult, { type: 'short' });
}
},
// Month: January, February, ..., December
'MMMM': {
unit: 'month',
match: function match(string, options) {
return options.locale.match.months(string, { type: 'long' }) || options.locale.match.months(string, { type: 'short' });
},
parse: function parse(matchResult, options) {
var parseResult = options.locale.match.month(matchResult, { type: 'long' });
if (parseResult == null) {
parseResult = options.locale.match.month(matchResult, { type: 'short' });
}
return parseResult;
}
},
// ISO week: 1, 2, ..., 53
'W': {
unit: 'isoWeek',
match: patterns.W,
parse: parseDecimal
},
// Ordinal ISO week
'Wo': {
unit: 'isoWeek',
match: function match(string, options) {
return options.locale.match.ordinalNumbers(string, { unit: 'isoWeek' });
},
parse: function parse(matchResult, options) {
return options.locale.match.ordinalNumber(matchResult, { unit: 'isoWeek' });
}
},
// ISO week: 01, 02, ..., 53
'WW': {
unit: 'isoWeek',
match: patterns.twoDigits,
parse: parseDecimal
},
// Day of week: 0, 1, ..., 6
'd': {
unit: 'dayOfWeek',
match: patterns.singleDigit,
parse: parseDecimal
},
// Ordinal day of week
'do': {
unit: 'dayOfWeek',
match: function match(string, options) {
return options.locale.match.ordinalNumbers(string, { unit: 'dayOfWeek' });
},
parse: function parse(matchResult, options) {
return options.locale.match.ordinalNumber(matchResult, { unit: 'dayOfWeek' });
}
},
// Day of week: Su, Mo, ..., Sa
'dd': {
unit: 'dayOfWeek',
match: function match(string, options) {
return options.locale.match.weekdays(string, { type: 'narrow' });
},
parse: function parse(matchResult, options) {
return options.locale.match.weekday(matchResult, { type: 'narrow' });
}
},
// Day of week: Sun, Mon, ..., Sat
'ddd': {
unit: 'dayOfWeek',
match: function match(string, options) {
return options.locale.match.weekdays(string, { type: 'short' }) || options.locale.match.weekdays(string, { type: 'narrow' });
},
parse: function parse(matchResult, options) {
var parseResult = options.locale.match.weekday(matchR