ngx-bootstrap
Version:
Angular Bootstrap
1 lines • 519 kB
Source Map (JSON)
{"version":3,"file":"ngx-bootstrap-chronos.mjs","sources":["../../../../src/chronos/utils.ts","../../../../src/chronos/utils/type-checks.ts","../../../../src/chronos/units/aliases.ts","../../../../src/chronos/units/constants.ts","../../../../src/chronos/utils/zero-fill.ts","../../../../src/chronos/format/format.ts","../../../../src/chronos/create/date-from-array.ts","../../../../src/chronos/utils/date-getters.ts","../../../../src/chronos/parse/regex.ts","../../../../src/chronos/parse/token.ts","../../../../src/chronos/units/priorities.ts","../../../../src/chronos/units/day-of-month.ts","../../../../src/chronos/create/parsing-flags.ts","../../../../src/chronos/units/year.ts","../../../../src/chronos/units/month.ts","../../../../src/chronos/utils/date-setters.ts","../../../../src/chronos/create/clone.ts","../../../../src/chronos/utils/start-end-of.ts","../../../../src/chronos/units/day-of-year.ts","../../../../src/chronos/units/week-calendar-utils.ts","../../../../src/chronos/locale/locale.class.ts","../../../../src/chronos/locale/calendar.ts","../../../../src/chronos/locale/locale.defaults.ts","../../../../src/chronos/utils/compare-arrays.ts","../../../../src/chronos/units/week.ts","../../../../src/chronos/units/week-year.ts","../../../../src/chronos/units/timezone.ts","../../../../src/chronos/units/timestamp.ts","../../../../src/chronos/units/second.ts","../../../../src/chronos/units/quarter.ts","../../../../src/chronos/units/offset.ts","../../../../src/chronos/units/minute.ts","../../../../src/chronos/units/millisecond.ts","../../../../src/chronos/units/hour.ts","../../../../src/chronos/locale/locales.ts","../../../../src/chronos/duration/valid.ts","../../../../src/chronos/utils/abs-ceil.ts","../../../../src/chronos/duration/bubble.ts","../../../../src/chronos/duration/humanize.ts","../../../../src/chronos/duration/constructor.ts","../../../../src/chronos/create/valid.ts","../../../../src/chronos/create/from-string.ts","../../../../src/chronos/format.ts","../../../../src/chronos/utils/defaults.ts","../../../../src/chronos/create/from-array.ts","../../../../src/chronos/create/check-overflow.ts","../../../../src/chronos/create/from-string-and-format.ts","../../../../src/chronos/create/from-string-and-array.ts","../../../../src/chronos/create/from-object.ts","../../../../src/chronos/create/from-anything.ts","../../../../src/chronos/create/local.ts","../../../../src/chronos/utils/abs-round.ts","../../../../src/chronos/utils/date-compare.ts","../../../../src/chronos/duration/create.ts","../../../../src/chronos/moment/add-subtract.ts","../../../../src/chronos/units/day-of-week.ts","../../../../src/chronos/i18n/ar.ts","../../../../src/chronos/i18n/bg.ts","../../../../src/chronos/i18n/ca.ts","../../../../src/chronos/i18n/cs.ts","../../../../src/chronos/i18n/da.ts","../../../../src/chronos/i18n/de.ts","../../../../src/chronos/i18n/en-gb.ts","../../../../src/chronos/i18n/es-do.ts","../../../../src/chronos/i18n/es.ts","../../../../src/chronos/i18n/es-pr.ts","../../../../src/chronos/i18n/es-us.ts","../../../../src/chronos/i18n/et.ts","../../../../src/chronos/i18n/fi.ts","../../../../src/chronos/i18n/fr.ts","../../../../src/chronos/i18n/fr-ca.ts","../../../../src/chronos/i18n/gl.ts","../../../../src/chronos/i18n/he.ts","../../../../src/chronos/i18n/hi.ts","../../../../src/chronos/i18n/hu.ts","../../../../src/chronos/i18n/hr.ts","../../../../src/chronos/i18n/id.ts","../../../../src/chronos/i18n/it.ts","../../../../src/chronos/i18n/ja.ts","../../../../src/chronos/i18n/ka.ts","../../../../src/chronos/i18n/kk.ts","../../../../src/chronos/i18n/ko.ts","../../../../src/chronos/i18n/lt.ts","../../../../src/chronos/i18n/lv.ts","../../../../src/chronos/i18n/mn.ts","../../../../src/chronos/i18n/nb.ts","../../../../src/chronos/i18n/nl-be.ts","../../../../src/chronos/i18n/nl.ts","../../../../src/chronos/i18n/pl.ts","../../../../src/chronos/i18n/pt-br.ts","../../../../src/chronos/i18n/ro.ts","../../../../src/chronos/i18n/ru.ts","../../../../src/chronos/i18n/sk.ts","../../../../src/chronos/i18n/sl.ts","../../../../src/chronos/i18n/sq.ts","../../../../src/chronos/i18n/sv.ts","../../../../src/chronos/i18n/th.ts","../../../../src/chronos/i18n/th-be.ts","../../../../src/chronos/i18n/tr.ts","../../../../src/chronos/i18n/uk.ts","../../../../src/chronos/i18n/vi.ts","../../../../src/chronos/i18n/zh-cn.ts","../../../../src/chronos/i18n/fa.ts","../../../../src/chronos/ngx-bootstrap-chronos.ts"],"sourcesContent":["\n\nexport function mod(n: number, x: number): number {\n return (n % x + x) % x;\n}\n\nexport function absFloor(num: number): number {\n return num < 0 ? Math.ceil(num) || 0 : Math.floor(num);\n}\n\n","import { absFloor } from '../utils';\n\nexport function isString(str: any): str is string {\n return typeof str === 'string';\n}\n\nexport function isDate(value: any): value is Date {\n return value instanceof Date || Object.prototype.toString.call(value) === '[object Date]';\n}\n\nexport function isBoolean(value: any): value is boolean {\n return value === true || value === false;\n}\n\nexport function isDateValid(date: Date): boolean {\n return date && date.getTime && !isNaN(date.getTime());\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function isFunction(fn: any): fn is Function {\n return (\n fn instanceof Function ||\n Object.prototype.toString.call(fn) === '[object Function]'\n );\n}\n\nexport function isNumber(value?: any): value is number {\n return typeof value === 'number' || Object.prototype.toString.call(value) === '[object Number]';\n}\n\nexport function isArray<T>(input?: any): input is T[] {\n return (\n input instanceof Array ||\n Object.prototype.toString.call(input) === '[object Array]'\n );\n}\n\nexport function hasOwnProp<T>(a: T /*object*/, b: string): b is Extract<keyof T, string> {\n return Object.prototype.hasOwnProperty.call(a, b);\n}\n\nexport function isObject<T>(input: any /*object*/): input is T {\n // IE8 will treat undefined and null as object if it wasn't for\n // input != null\n return (\n input != null && Object.prototype.toString.call(input) === '[object Object]'\n );\n}\n\nexport function isObjectEmpty(obj: any): boolean {\n if (Object.getOwnPropertyNames) {\n return (Object.getOwnPropertyNames(obj).length === 0);\n }\n let k;\n for (k in obj) {\n // eslint-disable-next-line no-prototype-builtins\n if (obj.hasOwnProperty(k)) {\n return false;\n }\n }\n\n return true;\n}\n\n\nexport function isUndefined(input: any): boolean {\n return input === void 0;\n}\n\nexport function toInt<T>(argumentForCoercion: string | number | T): number {\n const coercedNumber = +argumentForCoercion;\n let value = 0;\n\n if (coercedNumber !== 0 && isFinite(coercedNumber)) {\n value = absFloor(coercedNumber);\n }\n\n return value;\n}\n","import { hasOwnProp, isString } from '../utils/type-checks';\nimport { DateObject, UnitOfTime } from '../types';\n\nconst aliases: { [key: string]: string } = {};\n\nexport type ExtendedUnitOfTime = UnitOfTime | 'date' | 'week' | 'isoWeek' | 'dayOfYear' |\n 'weekday' | 'isoWeekday' | 'second' | 'millisecond' | 'minute' | 'hour' | 'quarter' | 'weekYear' | 'isoWeekYear';\n\nconst _mapUnits: { [key: string]: UnitOfTime } = {\n date: 'day',\n hour: 'hours',\n minute: 'minutes',\n second: 'seconds',\n millisecond: 'milliseconds'\n};\n\nexport function addUnitAlias(unit: ExtendedUnitOfTime, shorthand: string): void {\n const lowerCase = unit.toLowerCase();\n let _unit = unit;\n if (lowerCase in _mapUnits) {\n _unit = _mapUnits[lowerCase];\n }\n aliases[lowerCase] = aliases[`${lowerCase}s`] = aliases[shorthand] = _unit;\n}\n\nexport function normalizeUnits(units: string | string[]): string {\n return isString(units) ? aliases[units] || aliases[units.toLowerCase()] : undefined;\n}\n\nexport function normalizeObjectUnits(inputObject: Record<string, unknown>): DateObject {\n const normalizedInput: Record<string, unknown> = {};\n let normalizedProp;\n let prop;\n\n for (prop in inputObject) {\n if (hasOwnProp(inputObject, prop)) {\n normalizedProp = normalizeUnits(prop);\n if (normalizedProp) {\n normalizedInput[normalizedProp] = inputObject[prop];\n }\n }\n }\n\n return normalizedInput;\n}\n","// place in new Date([array])\nexport const YEAR = 0;\nexport const MONTH = 1;\nexport const DATE = 2;\nexport const HOUR = 3;\nexport const MINUTE = 4;\nexport const SECOND = 5;\nexport const MILLISECOND = 6;\nexport const WEEK = 7;\nexport const WEEKDAY = 8;\n","export function zeroFill(num: number,\n targetLength: number,\n forceSign?: boolean): string {\n const absNumber = `${Math.abs(num)}`;\n const zerosToFill = targetLength - absNumber.length;\n const sign = num >= 0;\n const _sign = sign ? (forceSign ? '+' : '') : '-';\n // todo: this is crazy slow\n const _zeros = Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1);\n\n return (_sign + _zeros + absNumber);\n}\n","import { Locale } from '../locale/locale.class';\nimport { zeroFill } from '../utils/zero-fill';\nimport { isFunction } from '../utils/type-checks';\nimport { DateFormatterOptions, DateFormatterFn } from '../types';\n\nexport const formatFunctions: {\n [key: string]: (date: Date, locale: Locale, isUTC?: boolean, offset?: number) => string;\n} = {};\nexport const formatTokenFunctions: { [key: string]: DateFormatterFn } = {};\n\nexport const formattingTokens = /(\\[[^\\[]*\\])|(\\\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;\n\n// token: 'M'\n// padded: ['MM', 2]\n// ordinal: 'Mo'\n// callback: function () { this.month() + 1 }\nexport function addFormatToken(token: string,\n padded: [string, number, boolean],\n ordinal: string,\n callback: DateFormatterFn): void {\n\n if (token) {\n formatTokenFunctions[token] = callback;\n }\n\n if (padded) {\n formatTokenFunctions[padded[0]] = function (): string {\n return zeroFill(callback.apply(null, arguments), padded[1], padded[2]);\n };\n }\n\n if (ordinal) {\n formatTokenFunctions[ordinal] = function (date: Date, opts: DateFormatterOptions): string {\n return opts.locale.ordinal(callback.apply(null, arguments), token);\n };\n }\n}\n\nexport function makeFormatFunction(format: string):\n (date: Date, locale: Locale, isUTC?: boolean, offset?: number) => string {\n\n const array: string[] = format.match(formattingTokens);\n const length = array.length;\n\n const formatArr: string[] | DateFormatterFn[] = new Array(length);\n\n for (let i = 0; i < length; i++) {\n formatArr[i] = formatTokenFunctions[array[i]]\n ? formatTokenFunctions[array[i]]\n : removeFormattingTokens(array[i]);\n }\n\n return function (date: Date, locale: Locale, isUTC: boolean, offset = 0): string {\n\n let output = '';\n for (let j = 0; j < length; j++) {\n output += isFunction(formatArr[j])\n ? (formatArr[j] as DateFormatterFn).call(null, date, {format, locale, isUTC, offset})\n : formatArr[j];\n }\n\n return output;\n };\n}\n\nfunction removeFormattingTokens(input: string): string {\n if (input.match(/\\[[\\s\\S]/)) {\n return input.replace(/^\\[|\\]$/g, '');\n }\n\n return input.replace(/\\\\/g, '');\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function createUTCDate(y?: number, m?: number, d?: number): Date {\n // eslint-disable-next-line prefer-rest-params\n const date = new Date(Date.UTC.apply(null, arguments));\n\n // the Date.UTC function remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {\n date.setUTCFullYear(y);\n }\n\n return date;\n}\n\nexport function createDate(y?: number,\n m = 0,\n d = 1,\n h = 0,\n M = 0,\n s = 0,\n ms = 0): Date {\n const date = new Date(y, m, d, h, M, s, ms);\n\n // the date constructor remaps years 0-99 to 1900-1999\n if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {\n date.setFullYear(y);\n }\n\n return date;\n}\n","import { createDate } from '../create/date-from-array';\n\nexport function getHours(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCHours() : date.getHours();\n}\n\nexport function getMinutes(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCMinutes() : date.getMinutes();\n}\n\nexport function getSeconds(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCSeconds() : date.getSeconds();\n}\n\nexport function getMilliseconds(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCMilliseconds() : date.getMilliseconds();\n}\nexport function getTime(date: Date): number {\n return date.getTime();\n}\n\nexport function getDay(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCDay() : date.getDay();\n}\n\nexport function getDate(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCDate() : date.getDate();\n}\n\nexport function getMonth(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCMonth() : date.getMonth();\n}\n\nexport function getFullYear(date: Date, isUTC = false): number {\n return isUTC ? date.getUTCFullYear() : date.getFullYear();\n}\n\nexport function getUnixTime(date: Date): number {\n return Math.floor(date.valueOf() / 1000);\n}\n\nexport function unix(date: Date): number {\n return Math.floor(date.valueOf() / 1000);\n}\n\nexport function getFirstDayOfMonth(date: Date): Date {\n return createDate(\n date.getFullYear(),\n date.getMonth(),\n 1,\n date.getHours(),\n date.getMinutes(),\n date.getSeconds()\n );\n}\n\nexport function daysInMonth(date: Date): number {\n return _daysInMonth(date.getFullYear(), date.getMonth());\n}\n\nexport function _daysInMonth(year: number, month: number): number {\n return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();\n}\n\nexport function isFirstDayOfWeek(date: Date, firstDayOfWeek?: number): boolean {\n return date.getDay() === Number(firstDayOfWeek);\n}\n\nexport function isSameMonth(date1?: Date, date2?: Date) {\n if (!date1 || !date2) {\n return false;\n }\n\n return isSameYear(date1, date2) && getMonth(date1) === getMonth(date2);\n}\n\nexport function isSameYear(date1?: Date, date2?: Date) {\n if (!date1 || !date2) {\n return false;\n }\n\n return getFullYear(date1) === getFullYear(date2);\n}\n\nexport function isSameDay(date1?: Date, date2?: Date): boolean {\n if (!date1 || !date2) {\n return false;\n }\n\n return (\n isSameYear(date1, date2) &&\n isSameMonth(date1, date2) &&\n getDate(date1) === getDate(date2)\n );\n}\n","import { hasOwnProp, isFunction } from '../utils/type-checks';\nimport { Locale } from '../locale/locale.class';\n\nexport const match1 = /\\d/; // 0 - 9\nexport const match2 = /\\d\\d/; // 00 - 99\nexport const match3 = /\\d{3}/; // 000 - 999\nexport const match4 = /\\d{4}/; // 0000 - 9999\nexport const match6 = /[+-]?\\d{6}/; // -999999 - 999999\nexport const match1to2 = /\\d\\d?/; // 0 - 99\nexport const match3to4 = /\\d\\d\\d\\d?/; // 999 - 9999\nexport const match5to6 = /\\d\\d\\d\\d\\d\\d?/; // 99999 - 999999\nexport const match1to3 = /\\d{1,3}/; // 0 - 999\nexport const match1to4 = /\\d{1,4}/; // 0 - 9999\nexport const match1to6 = /[+-]?\\d{1,6}/; // -999999 - 999999\n\nexport const matchUnsigned = /\\d+/; // 0 - inf\nexport const matchSigned = /[+-]?\\d+/; // -inf - inf\n\nexport const matchOffset = /Z|[+-]\\d\\d:?\\d\\d/gi; // +00:00 -00:00 +0000 -0000 or Z\nexport const matchShortOffset = /Z|[+-]\\d\\d(?::?\\d\\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z\n\nexport const matchTimestamp = /[+-]?\\d+(\\.\\d{1,3})?/; // 123456789 123456789.123\n\n// any word (or two) characters or numbers including two/three word month in arabic.\n// includes scottish gaelic two word and hyphenated months\nexport const matchWord = /[0-9]{0,256}['a-z\\u00A0-\\u05FF\\u0700-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]{1,256}|[\\u0600-\\u06FF\\/]{1,256}(\\s*?[\\u0600-\\u06FF]{1,256}){1,2}/i;\n\nexport type RegExpTokenFn = (isStrict: boolean, locale: Locale) => RegExp;\nconst regexes: {[key: string]: RegExpTokenFn} = {};\n\n\nexport function addRegexToken(token: string, regex: RegExp | RegExpTokenFn, strictRegex?: RegExp): void {\n if (isFunction(regex)) {\n regexes[token] = regex;\n\n return;\n }\n\n regexes[token] = function (isStrict: boolean, locale: Locale) {\n return (isStrict && strictRegex) ? strictRegex : regex;\n };\n}\n\nexport function getParseRegexForToken(token: string, locale: Locale): RegExp {\n const _strict = false;\n if (!hasOwnProp(regexes, token)) {\n return new RegExp(unescapeFormat(token));\n }\n\n return regexes[token](_strict, locale);\n}\n\n// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript\nfunction unescapeFormat(str: string): string {\n return regexEscape(str\n .replace('\\\\', '')\n .replace(/\\\\(\\[)|\\\\(\\])|\\[([^\\]\\[]*)\\]|\\\\(.)/g, (matched, p1, p2, p3, p4) => p1 || p2 || p3 || p4)\n );\n}\n\nexport function regexEscape(str: string): string {\n return str.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n","import { hasOwnProp, isArray, isFunction, isNumber, isString, toInt } from '../utils/type-checks';\nimport { DateParsingConfig } from '../create/parsing.types';\nimport { DateArray, DateParseTokenFn } from '../types';\n\nconst tokens: {[key: string]: DateParseTokenFn} = {};\n\nexport function addParseToken(token: string | string[], callback: DateParseTokenFn | number) {\n const _token = isString(token) ? [token] : token;\n let func = callback;\n\n if (isNumber(callback)) {\n func = function (input: string, array: DateArray, config: DateParsingConfig): DateParsingConfig {\n array[callback] = toInt(input);\n\n return config;\n };\n }\n\n if (isArray<string>(_token) && isFunction(func)) {\n let i;\n for (i = 0; i < _token.length; i++) {\n tokens[_token[i]] = func;\n }\n }\n}\n\nexport function addWeekParseToken(token: string[], callback: DateParseTokenFn): void {\n addParseToken(token, function (input: string, array: DateArray, config: DateParsingConfig, _token: string): DateParsingConfig {\n config._w = config._w || {};\n\n return callback(input, config._w, config, _token);\n });\n}\n\n\nexport function addTimeToArrayFromToken(token: string, input: string, config: DateParsingConfig): DateParsingConfig {\n if (input != null && hasOwnProp(tokens, token)) {\n tokens[token](input, config._a, config, token);\n }\n\n return config;\n}\n","const priorities: {[key: string]: number} = {};\n\nexport function addUnitPriority(unit: string, priority: number): void {\n priorities[unit] = priority;\n}\n\n/*\nexport function getPrioritizedUnits(unitsObj) {\n const units = [];\n let unit;\n for (unit in unitsObj) {\n if (unitsObj.hasOwnProperty(unit)) {\n units.push({ unit, priority: priorities[unit] });\n }\n }\n units.sort(function (a, b) {\n return a.priority - b.priority;\n });\n\n return units;\n}\n*/\n","import { addFormatToken } from '../format/format';\nimport { getDate } from '../utils/date-getters';\nimport { addRegexToken, match1to2, match2 } from '../parse/regex';\nimport { addParseToken } from '../parse/token';\nimport { DATE } from './constants';\nimport { toInt } from '../utils/type-checks';\nimport { DateArray, DateFormatterOptions } from '../types';\nimport { addUnitAlias } from './aliases';\nimport { addUnitPriority } from './priorities';\nimport { DateParsingConfig } from '../create/parsing.types';\n\n\nexport function initDayOfMonth() {\n// FORMATTING\n\n addFormatToken('D', ['DD', 2, false], 'Do',\n function(date: Date, opts: DateFormatterOptions): string {\n return getDate(date, opts.isUTC)\n .toString(10);\n }\n );\n\n// ALIASES\n\n addUnitAlias('date', 'D');\n\n// PRIOROITY\n addUnitPriority('date', 9);\n\n// PARSING\n\n addRegexToken('D', match1to2);\n addRegexToken('DD', match1to2, match2);\n addRegexToken('Do', function(isStrict, locale) {\n return locale._dayOfMonthOrdinalParse || locale._ordinalParse;\n });\n\n addParseToken(['D', 'DD'], DATE);\n addParseToken(\n 'Do',\n function(input: string, array: DateArray, config: DateParsingConfig): DateParsingConfig {\n array[DATE] = toInt(input.match(match1to2)[0]);\n\n return config;\n }\n );\n}\n","import { DateParsingConfig, DateParsingFlags } from './parsing.types';\n\nfunction defaultParsingFlags(): DateParsingFlags {\n // We need to deep clone this object.\n return {\n empty: false,\n unusedTokens: [],\n unusedInput: [],\n overflow: -2,\n charsLeftOver: 0,\n nullInput: false,\n invalidMonth: null,\n invalidFormat: false,\n userInvalidated: false,\n iso: false,\n parsedDateParts: [],\n meridiem: null,\n rfc2822: false,\n weekdayMismatch: false\n };\n}\n\nexport function getParsingFlags(config: DateParsingConfig): DateParsingFlags {\n if (config._pf == null) {\n config._pf = defaultParsingFlags();\n }\n\n return config._pf;\n}\n","import { addFormatToken } from '../format/format';\nimport { getFullYear } from '../utils/date-getters';\nimport { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex';\nimport { addParseToken } from '../parse/token';\nimport { YEAR } from './constants';\nimport { toInt } from '../utils/type-checks';\nimport { addUnitPriority } from './priorities';\nimport { addUnitAlias } from './aliases';\nimport { DateFormatterOptions } from '../types';\n\n// FORMATTING\n\nfunction getYear(date: Date, opts: DateFormatterOptions): string {\n if (opts.locale.getFullYear) {\n return opts.locale.getFullYear(date, opts.isUTC).toString();\n }\n return getFullYear(date, opts.isUTC).toString();\n}\n\nexport function initYear() {\n addFormatToken('Y', null, null,\n function (date: Date, opts: DateFormatterOptions): string {\n const y = getFullYear(date, opts.isUTC);\n\n return y <= 9999 ? y.toString(10) : `+${y}`;\n });\n\n addFormatToken(null, ['YY', 2, false], null,\n function (date: Date, opts: DateFormatterOptions): string {\n return (getFullYear(date, opts.isUTC) % 100).toString(10);\n });\n\n addFormatToken(null, ['YYYY', 4, false], null, getYear);\n addFormatToken(null, ['YYYYY', 5, false], null, getYear);\n addFormatToken(null, ['YYYYYY', 6, true], null, getYear);\n\n // ALIASES\n\n addUnitAlias('year', 'y');\n\n // PRIORITIES\n\n addUnitPriority('year', 1);\n\n // PARSING\n\n addRegexToken('Y', matchSigned);\n addRegexToken('YY', match1to2, match2);\n addRegexToken('YYYY', match1to4, match4);\n addRegexToken('YYYYY', match1to6, match6);\n addRegexToken('YYYYYY', match1to6, match6);\n\n addParseToken(['YYYYY', 'YYYYYY'], YEAR);\n addParseToken('YYYY', function (input, array, config) {\n array[YEAR] = input.length === 2 ? parseTwoDigitYear(input) : toInt(input);\n\n return config;\n });\n addParseToken('YY', function (input, array, config) {\n array[YEAR] = parseTwoDigitYear(input);\n\n return config;\n });\n addParseToken('Y', function (input, array, config) {\n array[YEAR] = parseInt(input, 10);\n\n return config;\n });\n}\n\nexport function parseTwoDigitYear(input: string): number {\n return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);\n}\n\nexport function daysInYear(year: number): number {\n return isLeapYear(year) ? 366 : 365;\n}\n\nexport function isLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n","import { addFormatToken } from '../format/format';\nimport { isLeapYear } from './year';\nimport { mod } from '../utils';\nimport { getMonth } from '../utils/date-getters';\nimport { addRegexToken, match1to2, match2 } from '../parse/regex';\nimport { addParseToken } from '../parse/token';\nimport { MONTH } from './constants';\nimport { toInt } from '../utils/type-checks';\nimport { addUnitPriority } from './priorities';\nimport { addUnitAlias } from './aliases';\nimport { getParsingFlags } from '../create/parsing-flags';\nimport { DateParsingConfig } from '../create/parsing.types';\nimport { DateArray, DateFormatterOptions } from '../types';\n\n// todo: this is duplicate, source in date-getters.ts\nexport function daysInMonth(year: number, month: number): number {\n if (isNaN(year) || isNaN(month)) {\n return NaN;\n }\n const modMonth = mod(month, 12);\n const _year = year + (month - modMonth) / 12;\n\n return modMonth === 1\n ? isLeapYear(_year) ? 29 : 28\n : (31 - modMonth % 7 % 2);\n}\n\nexport function initMonth() {\n// FORMATTING\n\n addFormatToken('M', ['MM', 2, false], 'Mo',\n function(date: Date, opts: DateFormatterOptions): string {\n return (getMonth(date, opts.isUTC) + 1).toString(10);\n }\n );\n\n addFormatToken('MMM', null, null,\n function(date: Date, opts: DateFormatterOptions): string {\n return opts.locale.monthsShort(date, opts.format, opts.isUTC);\n }\n );\n\n addFormatToken('MMMM', null, null,\n function(date: Date, opts: DateFormatterOptions): string {\n return opts.locale.months(date, opts.format, opts.isUTC);\n }\n );\n\n\n// ALIASES\n\n addUnitAlias('month', 'M');\n\n// PRIORITY\n\n addUnitPriority('month', 8);\n\n// PARSING\n\n addRegexToken('M', match1to2);\n addRegexToken('MM', match1to2, match2);\n addRegexToken('MMM', function(isStrict, locale) {\n return locale.monthsShortRegex(isStrict);\n });\n addRegexToken('MMMM', function(isStrict, locale) {\n return locale.monthsRegex(isStrict);\n });\n\n addParseToken(['M', 'MM'], function(input: string, array: DateArray, config: DateParsingConfig): DateParsingConfig {\n array[MONTH] = toInt(input) - 1;\n\n return config;\n });\n\n addParseToken(\n ['MMM', 'MMMM'],\n function(input: string, array: DateArray, config: DateParsingConfig, token: string): DateParsingConfig {\n const month = config._locale.monthsParse(input, token, config._strict);\n // if we didn't find a month name, mark the date as invalid.\n if (month != null) {\n array[MONTH] = month;\n } else {\n getParsingFlags(config).invalidMonth = !!input;\n }\n\n return config;\n }\n );\n}\n","import { TimeUnit } from '../types';\nimport { daysInMonth } from '../units/month';\nimport { isNumber } from './type-checks';\nimport { getDate, getFullYear, getMonth } from './date-getters';\nimport { isLeapYear } from '../units/year';\nimport { createDate } from '../create/date-from-array';\n\nconst defaultTimeUnit: TimeUnit = {\n year: 0,\n month: 0,\n day: 0,\n hour: 0,\n minute: 0,\n seconds: 0\n};\n\nexport function shiftDate(date: Date, unit: TimeUnit): Date {\n const _unit = Object.assign({}, defaultTimeUnit, unit);\n const year = date.getFullYear() + (_unit.year || 0);\n const month = date.getMonth() + (_unit.month || 0);\n let day = date.getDate() + (_unit.day || 0);\n if (_unit.month && !_unit.day) {\n day = Math.min(day, daysInMonth(year, month));\n }\n\n return createDate(\n year,\n month,\n day,\n date.getHours() + (_unit.hour || 0),\n date.getMinutes() + (_unit.minute || 0),\n date.getSeconds() + (_unit.seconds || 0)\n );\n}\n\nexport function setFullDate(date: Date, unit: TimeUnit): Date {\n return createDate(\n getNum(date.getFullYear(), unit.year),\n getNum(date.getMonth(), unit.month),\n 1, // day, to avoid issue with wrong months selection at the end of current month (#5371)\n getNum(date.getHours(), unit.hour),\n getNum(date.getMinutes(), unit.minute),\n getNum(date.getSeconds(), unit.seconds),\n getNum(date.getMilliseconds(), unit.milliseconds)\n );\n}\n\nfunction getNum(def: number, num?: number): number {\n return isNumber(num) ? num : def;\n}\n\nexport function setFullYear(date: Date, value: number, isUTC?: boolean): Date {\n const _month = getMonth(date, isUTC);\n const _date = getDate(date, isUTC);\n const _year = getFullYear(date, isUTC);\n if (isLeapYear(_year) && _month === 1 && _date === 29) {\n const _daysInMonth = daysInMonth(value, _month);\n isUTC ? date.setUTCFullYear(value, _month, _daysInMonth) : date.setFullYear(value, _month, _daysInMonth);\n }\n\n isUTC ? date.setUTCFullYear(value) : date.setFullYear(value);\n\n return date;\n}\n\nexport function setMonth(date: Date, value: number, isUTC?: boolean): Date {\n const dayOfMonth = Math.min(getDate(date), daysInMonth(getFullYear(date), value));\n isUTC ? date.setUTCMonth(value, dayOfMonth) : date.setMonth(value, dayOfMonth);\n\n return date;\n}\n\nexport function setDay(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCDate(value) : date.setDate(value);\n\n return date;\n}\n\nexport function setHours(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCHours(value) : date.setHours(value);\n\n return date;\n}\n\nexport function setMinutes(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCMinutes(value) : date.setMinutes(value);\n\n return date;\n}\n\nexport function setSeconds(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCSeconds(value) : date.setSeconds(value);\n\n return date;\n}\n\nexport function setMilliseconds(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCMilliseconds(value) : date.setMilliseconds(value);\n\n return date;\n}\n\nexport function setDate(date: Date, value: number, isUTC?: boolean): Date {\n isUTC ? date.setUTCDate(value) : date.setDate(value);\n\n return date;\n}\n\nexport function setTime(date: Date, value: number): Date {\n date.setTime(value);\n\n return date;\n}\n","// fastest way to clone date\n// https://jsperf.com/clone-date-object2\nexport function cloneDate(date: Date): Date {\n return new Date(date.getTime());\n}\n","import { TimeUnit, UnitOfTime } from '../types';\nimport {\n setDate, setFullDate, setHours, setMilliseconds, setMinutes, setMonth, setSeconds,\n shiftDate\n} from './date-setters';\nimport { cloneDate } from '../create/clone';\nimport { setISODayOfWeek, setLocaleDayOfWeek } from '../units/day-of-week';\nimport { getMonth } from './date-getters';\nimport { add, subtract } from '../moment/add-subtract';\n\nexport function startOf(date: Date, unit: UnitOfTime, isUTC?: boolean): Date {\n const _date = cloneDate(date);\n // the following switch intentionally omits break keywords\n // to utilize falling through the cases.\n switch (unit) {\n case 'year':\n setMonth(_date, 0, isUTC);\n /* falls through */\n case 'quarter':\n case 'month':\n setDate(_date, 1, isUTC);\n /* falls through */\n case 'week':\n case 'isoWeek':\n case 'day':\n case 'date':\n setHours(_date, 0, isUTC);\n /* falls through */\n case 'hours':\n setMinutes(_date, 0, isUTC);\n /* falls through */\n case 'minutes':\n setSeconds(_date, 0, isUTC);\n /* falls through */\n case 'seconds':\n setMilliseconds(_date, 0, isUTC);\n }\n\n // weeks are a special case\n if (unit === 'week') {\n setLocaleDayOfWeek(_date, 0, {isUTC});\n }\n if (unit === 'isoWeek') {\n setISODayOfWeek(_date, 1);\n }\n\n // quarters are also special\n if (unit === 'quarter') {\n setMonth(_date, Math.floor(getMonth(_date, isUTC) / 3) * 3, isUTC);\n }\n\n return _date;\n}\n\nexport function endOf(date: Date, unit: UnitOfTime, isUTC?: boolean): Date {\n let _unit = unit;\n // 'date' is an alias for 'day', so it should be considered as such.\n if (_unit === 'date') {\n _unit = 'day';\n }\n\n const start = startOf(date, _unit, isUTC);\n const _step = add(start, 1, _unit === 'isoWeek' ? 'week' : _unit, isUTC);\n const res = subtract(_step, 1, 'milliseconds', isUTC);\n\n return res;\n}\n","import { addFormatToken } from '../format/format';\nimport { startOf } from '../utils/start-end-of';\nimport { addRegexToken, match1to3, match3 } from '../parse/regex';\nimport { addParseToken } from '../parse/token';\nimport { addUnitPriority } from './priorities';\nimport { addUnitAlias } from './aliases';\nimport { DateArray, DateFormatterOptions } from '../types';\nimport { DateParsingConfig } from '../create/parsing.types';\nimport { toInt } from '../utils/type-checks';\nimport { add } from '../moment/add-subtract';\n\n\nexport function initDayOfYear() {\n// FORMATTING\n\n addFormatToken('DDD', ['DDDD', 3, false], 'DDDo',\n function(date: Date): string {\n return getDayOfYear(date)\n .toString(10);\n }\n );\n\n\n// ALIASES\n\n addUnitAlias('dayOfYear', 'DDD');\n\n// PRIORITY\n\n addUnitPriority('dayOfYear', 4);\n\n addRegexToken('DDD', match1to3);\n addRegexToken('DDDD', match3);\n addParseToken(\n ['DDD', 'DDDD'],\n function(input: string, array: DateArray, config: DateParsingConfig): DateParsingConfig {\n config._dayOfYear = toInt(input);\n\n return config;\n }\n );\n}\n\nexport function getDayOfYear(date: Date, isUTC?: boolean): number {\n const date1 = +startOf(date, 'day', isUTC);\n const date2 = +startOf(date, 'year', isUTC);\n const someDate = date1 - date2;\n const oneDay = 1000 * 60 * 60 * 24;\n\n return Math.round(someDate / oneDay) + 1;\n}\n\nexport function setDayOfYear(date: Date, input: number): Date {\n const dayOfYear = getDayOfYear(date);\n\n return add(date, (input - dayOfYear), 'day');\n}\n","/**\n *\n * @param {number} year\n * @param {number} dow - start-of-first-week\n * @param {number} doy - start-of-year\n * @returns {number}\n */\nimport { createUTCDate } from '../create/date-from-array';\nimport { daysInYear } from './year';\nimport { getDayOfYear } from './day-of-year';\nimport { getFullYear } from '../utils/date-getters';\n\nfunction firstWeekOffset(year: number, dow: number, doy: number): number {\n // first-week day -- which january is always in the first week (4 for iso, 1 for other)\n const fwd = dow - doy + 7;\n // first-week day local weekday -- which local weekday is fwd\n const fwdlw = (createUTCDate(year, 0, fwd).getUTCDay() - dow + 7) % 7;\n\n return -fwdlw + fwd - 1;\n}\n\n// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday\nexport function dayOfYearFromWeeks(\n year: number,\n week: number,\n weekday: number,\n dow: number,\n doy: number\n): { year: number; dayOfYear: number } {\n const localWeekday = (7 + weekday - dow) % 7;\n const weekOffset = firstWeekOffset(year, dow, doy);\n const dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset;\n let resYear: number;\n let resDayOfYear: number;\n\n if (dayOfYear <= 0) {\n resYear = year - 1;\n resDayOfYear = daysInYear(resYear) + dayOfYear;\n } else if (dayOfYear > daysInYear(year)) {\n resYear = year + 1;\n resDayOfYear = dayOfYear - daysInYear(year);\n } else {\n resYear = year;\n resDayOfYear = dayOfYear;\n }\n\n return {\n year: resYear,\n dayOfYear: resDayOfYear\n };\n}\n\nexport function weekOfYear(date: Date, dow: number, doy: number, isUTC?: boolean): { week: number; year: number } {\n const weekOffset = firstWeekOffset(getFullYear(date, isUTC), dow, doy);\n const week = Math.floor((getDayOfYear(date, isUTC) - weekOffset - 1) / 7) + 1;\n let resWeek: number;\n let resYear: number;\n\n if (week < 1) {\n resYear = getFullYear(date, isUTC) - 1;\n resWeek = week + weeksInYear(resYear, dow, doy);\n } else if (week > weeksInYear(getFullYear(date, isUTC), dow, doy)) {\n resWeek = week - weeksInYear(getFullYear(date, isUTC), dow, doy);\n resYear = getFullYear(date, isUTC) + 1;\n } else {\n resYear = getFullYear(date, isUTC);\n resWeek = week;\n }\n\n return {\n week: resWeek,\n year: resYear\n };\n}\n\nexport function weeksInYear(year: number, dow: number, doy: number): number {\n const weekOffset = firstWeekOffset(year, dow, doy);\n const weekOffsetNext = firstWeekOffset(year + 1, dow, doy);\n\n return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;\n}\n","import { weekOfYear } from '../units/week-calendar-utils';\nimport { hasOwnProp, isArray, isFunction } from '../utils/type-checks';\nimport { getDay, getMonth, getFullYear } from '../utils/date-getters';\nimport { matchWord, regexEscape } from '../parse/regex';\nimport { setDayOfWeek } from '../units/day-of-week';\n\nexport interface LocaleOptionsFormat {\n format: string[];\n standalone: string[];\n isFormat?: RegExp;\n}\n\nexport type LocaleOptions = string[] | LocaleOptionsFormat;\n\nconst MONTHS_IN_FORMAT = /D[oD]?(\\[[^\\[\\]]*\\]|\\s)+MMMM?/;\nexport const defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(\n '_'\n);\nexport const defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(\n '_'\n);\nexport const defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(\n '_'\n);\nexport const defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split(\n '_'\n);\nexport const defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');\nexport const defaultLongDateFormat: { [index: string]: string } = {\n LTS: 'h:mm:ss A',\n LT: 'h:mm A',\n L: 'MM/DD/YYYY',\n LL: 'MMMM D, YYYY',\n LLL: 'MMMM D, YYYY h:mm A',\n LLLL: 'dddd, MMMM D, YYYY h:mm A'\n};\n\nexport const defaultOrdinal = '%d';\nexport const defaultDayOfMonthOrdinalParse = /\\d{1,2}/;\n\nconst defaultMonthsShortRegex = matchWord;\nconst defaultMonthsRegex = matchWord;\n\nexport type OrdinalDateFn = (num: number, token?: string) => string;\nexport type PluralizeDateFn = (num: number, withoutSuffix: boolean,\n key?: string, isFuture?: boolean) => string;\n\nexport interface LocaleData {\n abbr?: string;\n parentLocale?: string;\n\n months?: LocaleOptions | ((date: Date, format: string, isUTC?: boolean) => string | string[]);\n monthsShort?: LocaleOptions | ((date: Date, format: string, isUTC?: boolean) => string | string[]);\n monthsParseExact?: boolean;\n\n weekdays?: LocaleOptions | ((date: Date, format: string, isUTC?: boolean) => string | string[]);\n weekdaysShort?: string[] | ((date: Date, format: string, isUTC?: boolean) => string | string[]);\n weekdaysMin?: string[] | ((date: Date, format: string, isUTC?: boolean) => string | string[]);\n weekdaysParseExact?: boolean;\n\n longDateFormat?: { [index: string]: string };\n calendar?: {\n [key: string]: (string\n | ((date: Date, now?: Date) => string)\n | ((dayOfWeek: number, isNextWeek: boolean) => string))\n };\n relativeTime?: { [key: string]: string | PluralizeDateFn };\n dayOfMonthOrdinalParse?: RegExp;\n ordinal?: string | OrdinalDateFn;\n\n week?: { dow?: number; doy?: number };\n\n invalidDate?: string;\n\n monthsRegex?: RegExp;\n monthsParse?: RegExp[];\n monthsShortRegex?: RegExp;\n monthsStrictRegex?: RegExp;\n monthsShortStrictRegex?: RegExp;\n longMonthsParse?: RegExp[];\n shortMonthsParse?: RegExp[];\n\n meridiemParse?: RegExp;\n\n meridiemHour?(hour: number, meridiem: string): number;\n\n preparse?(str: string, format?: string | string[]): string;\n\n postformat?(str: string | number): string;\n\n meridiem?(hour: number, minute?: number, isLower?: boolean): string;\n\n isPM?(input: string): boolean;\n\n getFullYear?(date: Date, isUTC: boolean): number;\n}\n\nexport class Locale {\n parentLocale?: Locale;\n _abbr: string;\n _config: LocaleData;\n meridiemHour: (hour: number, meridiem: string) => number;\n\n _invalidDate: string;\n _week: { dow: number; doy: number };\n _dayOfMonthOrdinalParse: RegExp;\n _ordinalParse: RegExp;\n _meridiemParse: RegExp;\n\n private _calendar: { [key: string]: string };\n private _relativeTime: { future: string; past: string };\n private _months: LocaleOptions;\n private _monthsShort: LocaleOptions;\n private _monthsRegex: RegExp;\n private _monthsShortRegex: RegExp;\n private _monthsStrictRegex: RegExp;\n private _monthsShortStrictRegex: RegExp;\n private _monthsParse: RegExp[];\n private _longMonthsParse: string[] | RegExp[];\n private _shortMonthsParse: string[] | RegExp[];\n private _monthsParseExact: RegExp;\n private _weekdaysParseExact: boolean;\n private _weekdaysRegex: RegExp;\n private _weekdaysShortRegex: RegExp;\n private _weekdaysMinRegex: RegExp;\n\n private _weekdaysStrictRegex: RegExp;\n private _weekdaysShortStrictRegex: RegExp;\n private _weekdaysMinStrictRegex: RegExp;\n\n private _weekdays: LocaleOptions;\n private _weekdaysShort: string[];\n private _weekdaysMin: string[];\n private _weekdaysParse: string[] | RegExp[];\n private _minWeekdaysParse: string[] | RegExp[];\n private _shortWeekdaysParse: string[] | RegExp[];\n private _fullWeekdaysParse: RegExp[];\n private _longDateFormat: { [key: string]: string };\n\n private _ordinal: string;\n\n constructor(config: LocaleData) {\n if (config) {\n this.set(config);\n }\n }\n\n set(config: LocaleData): void {\n let confKey;\n for (confKey in config) {\n // eslint-disable-next-line no-prototype-builtins\n if (!config.hasOwnProperty(confKey)) {\n continue;\n }\n const prop = config[confKey as keyof LocaleData];\n const key = (isFunction(prop) ? confKey : `_${confKey}`) as keyof Locale;\n\n this[key] = prop as any;\n }\n\n this._config = config;\n }\n\n calendar(key: string, date: Date, now: Date): string {\n const output = this._calendar[key] || this._calendar[\"sameElse\"];\n\n return isFunction(output) ? output.call(null, date, now) : output;\n }\n\n longDateFormat(key: string) {\n const format = this._longDateFormat[key];\n const formatUpper = this._longDateFormat[key.toUpperCase()];\n\n if (format || !formatUpper) {\n return format;\n }\n\n this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val: string) {\n return val.slice(1);\n });\n\n return this._longDateFormat[key];\n }\n\n get invalidDate(): string {\n return this._invalidDate;\n }\n\n set invalidDate(val: string) {\n this._invalidDate = val;\n }\n\n ordinal(num: number, token?: string): string {\n return this._ordinal.replace('%d', num.toString(10));\n }\n\n preparse(str: string, format?: string | string[]) {\n return str;\n }\n\n\n getFullYear(date: Date, isUTC = false): number {\n return getFullYear(date, isUTC);\n }\n\n postformat(str: string) {\n return str;\n }\n\n relativeTime(num: number, withoutSuffix: boolean, str: 'future' | 'past', isFuture: boolean): string {\n const output = this._relativeTime[str];\n\n return (isFunction(output)) ?\n output(num, withoutSuffix, str, isFuture) :\n output.replace(/%d/i, num.toString(10));\n }\n\n pastFuture(diff: number, output: string): string {\n const format = this._relativeTime[diff > 0 ? 'future' : 'past'];\n\n return isFunction(format) ? format(output) : format.replace(/%s/i, output);\n }\n\n /** Months */\n months(): string[];\n months(date: Date, format?: string, isUTC?: boolean): string;\n months(date?: Date, format?: string, isUTC = false): string | string[] {\n if (!date) {\n return isArray<string>(this._months)\n ? this._months\n : this._months.standalone;\n }\n\n if (isArray<string>(this._months)) {\n return this._months[getMonth(date, isUTC)];\n }\n\n const key = (this._months.isFormat || MONTHS_IN_FORMAT).test(format)\n ? 'format'\n : 'standalone';\n\n return this._months[key][getMonth(date, isUTC)];\n }\n\n monthsShort(): string[];\n monthsShort(date?: Date, format?: string, isUTC?: boolean): string;\n monthsShort(date?: Date, format?: string, isUTC = false): string | string[] {\n if (!date) {\n return isArray<string>(this._monthsShort)\n ? this._monthsShort\n : this._monthsShort.standalone;\n }\n\n if (isArray<string>(this._monthsShort)) {\n return this._monthsShort[getMonth(date, isUTC)];\n }\n const key = MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone';\n\n return this._monthsShort[key][getMonth(date, isUTC)];\n }\n\n monthsParse(monthName: string, format?: string, strict?: boolean): number {\n let date;\n let regex;\n\n if (this._monthsParseExact) {\n return this.handleMonthStrictParse(monthName, format, strict);\n }\n\n if (!this._monthsParse) {\n this._monthsParse = [];\n this._longMonthsParse = [];\n this._shortMonthsParse = [];\n }\n\n // TODO: add sorting\n // Sorting makes sure if one month (or abbr) is a prefix of another\n // see sorting in computeMonthsParse\n let i;\n for (i = 0; i < 12; i++) {\n // make the regex if we don't have it already\n date = new Date(Date.UTC(2000, i));\n if (strict && !this._longMonthsParse[i]) {\n const _months = this.months(date, '', true).replace('.', '');\n const _shortMonths = this.monthsShort(date, '', true).replace('.', '');\n this._longMonthsParse[i] = new RegExp(`^${_months}$`, 'i');\n this._shortMonthsParse[i] = new RegExp(`^${_shortMonths}$`, 'i');\n }\n if (!strict && !this._monthsParse[i]) {\n regex = `^${this.months(date, '', true)}|^${this.monthsShort(date, '', true)}`;\n this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');\n }\n // testing the regex\n if (strict && format === 'MMMM' && (this._longMonthsParse[i] as RegExp).test(monthName)) {\n return i;\n }\n\n if (strict && format === 'MMM' && (this._shortMonthsParse[i] as RegExp).test(monthName)) {\n return i;\n }\n\n if (!strict && this._monthsParse[i].test(monthName)) {\n return i;\n }\n }\n }\n\n monthsRegex(isStrict: boolean): RegExp {\n if (this._monthsParseExact) {\n if (!hasOwnProp(this, '_monthsRegex')) {\n this.computeMonthsParse();\n }\n if (isStrict) {\n return this._monthsStrictRegex;\n }\n\n return this._monthsRegex;\n }\n\n if (!hasOwnProp(this, '_monthsRegex')) {\n this._monthsRegex = defaultMonthsRegex;\n }\n\n return this._monthsStrictRegex && isStrict ?\n this._monthsStrictRegex : this._monthsRegex;\n }\n\n monthsShortRegex(isStrict: boolean): RegExp {\n if (this._monthsParseExact) {\n if (!hasOwnProp(this, '_monthsRegex')) {\n this.computeMonthsParse();\n }\n if (isStrict) {\n return this._monthsShortStrictRegex;\n }\n\n return this._monthsShortRegex;\n }\n if (!hasOwnProp(this, '_monthsShortRegex')) {\n this._monthsShortRegex = defaultMonthsShortRegex;\n }\n\n return this._monthsShortStrictRegex && isStrict ?\n this._monthsShortStrictRegex : this._monthsShortRegex;\n }\n\n /** Week */\n week(date: Date, isUTC?: boolean): number {\n return weekOfYear(date, this._week.dow, this._week.doy, isUTC).week;\n }\n\n firstDayOfWeek(): number {\n return this._week.dow;\n }\n\n firstDayOfYear(): number {\n return this._week.doy;\n }\n\n /** Day of Week */\n weekdays(): string[];\n weekdays(date: Date, format?: string, isUTC?: boolean): string;\n weekdays(date?: Date, format?: string, isUTC?: boolean): string | string[] {\n if (!date) {\n return isArray<string>(this._weekdays)\n ? this._weekdays\n : this._weekdays.standalone;\n }\n\n if (isArray<string>(this._weekdays)) {\n return this._weekdays[getDay(date, isUTC)];\n }\n\n const _key = this._weekdays.isFormat.test(format)\n ? 'format'\n : 'standalone';\n\n return this._weekdays[_key][getDay(date, isUTC)];\n }\n\n weekdaysMin(): string[];\n weekdaysMin(date: Date, format?: string, isUTC?: boolean): string;\n weekdaysMin(date?: Date, format?: string, isUTC?: boolean): string | string[] {\n return date ? this._weekdaysMin[getDay(date, isUTC)] : this._weekdaysMin;\n }\n\n weekdaysShort(): string[];\n weekdaysShort(date: Date, format?: string, isUTC?: boolean): string;\n weekdaysShort(date?: Date, format?: string, isUTC?: boolean): string | string[] {\n return date ? this._weekdaysShort[getDay(date, isUTC)] : this._weekdaysShort;\n }\n\n\n // proto.weekdaysParse = localeWeekdaysParse;\n weekdaysParse(weekdayName?: string, format?: string, strict?: boolean): number {\n let i;\n let regex;\n\n if (this._weekdaysParseExact) {\n return this.handleWeekStrictParse(weekdayName, format, strict);\n }\n\n if (!this._weekdaysParse) {\n this._weekdaysParse = [];\n this._minWeekdaysParse = [];\n this._shortWeekdaysParse = [];\n this._fullWeekdaysParse = [];\n }\n\n for (i = 0; i < 7; i++) {\n // make the regex if we don't have it already\n // fix: here is the issue\n const date = setDayOfWeek(new Date(Date.UTC(2000, 1)), i, null, true);\n if (strict && !this._fullWeekdaysParse[i]) {\n this._fullWeekdaysParse[i] = new RegExp(`^${this.weekdays(date, '', true).replace('.', '\\.?')}$`, 'i');\n this._shortWeekdaysParse[i] = new RegExp(`^${this.weekdaysShort(date, '', true).replace('.', '\\.?')}$`, 'i');\n this._minWeekdaysParse[i] = new RegExp(`^${this.weekdaysMin(date, '', true).replace('.', '\\.?')}$`, 'i');\n }\n if (!this._weekdaysParse[i]) {\n regex = `^${this.weekdays(date, '', true)}|^${this.