registration
This commit is contained in:
97
frontend/style/node_modules/date-fns/parse.js
generated
vendored
97
frontend/style/node_modules/date-fns/parse.js
generated
vendored
@@ -1,31 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "longFormatters", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index5.longFormatters;
|
||||
},
|
||||
});
|
||||
exports.parse = parse;
|
||||
Object.defineProperty(exports, "parsers", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index7.parsers;
|
||||
},
|
||||
});
|
||||
var _index = require("./constructFrom.js");
|
||||
var _index2 = require("./getDefaultOptions.js");
|
||||
var _index3 = require("./_lib/defaultLocale.js");
|
||||
var _index4 = require("./toDate.js");
|
||||
import { defaultLocale } from "./_lib/defaultLocale.js";
|
||||
import { longFormatters } from "./_lib/format/longFormatters.js";
|
||||
import {
|
||||
isProtectedDayOfYearToken,
|
||||
isProtectedWeekYearToken,
|
||||
warnOrThrowProtectedError,
|
||||
} from "./_lib/protectedTokens.js";
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
import { getDefaultOptions } from "./getDefaultOptions.js";
|
||||
import { toDate } from "./toDate.js";
|
||||
|
||||
var _index5 = require("./_lib/format/longFormatters.js");
|
||||
var _index6 = require("./_lib/protectedTokens.js");
|
||||
|
||||
var _index7 = require("./parse/_lib/parsers.js");
|
||||
|
||||
var _Setter = require("./parse/_lib/Setter.js");
|
||||
import { DateTimezoneSetter } from "./parse/_lib/Setter.js";
|
||||
import { parsers } from "./parse/_lib/parsers.js";
|
||||
|
||||
// Rexports of internal for libraries to use.
|
||||
// See: https://github.com/date-fns/date-fns/issues/3638#issuecomment-1877082874
|
||||
export { longFormatters, parsers };
|
||||
|
||||
/**
|
||||
* The {@link parse} function options.
|
||||
@@ -240,7 +229,7 @@ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
||||
*
|
||||
* `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
|
||||
*
|
||||
* `parse` will try to match both formatting and stand-alone units interchangably.
|
||||
* `parse` will try to match both formatting and stand-alone units interchangeably.
|
||||
*
|
||||
* 2. Any sequence of the identical letters is a pattern, unless it is escaped by
|
||||
* the single quote characters (see below).
|
||||
@@ -289,7 +278,7 @@ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
||||
* 6. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
|
||||
* You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
||||
*
|
||||
* 7. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
|
||||
* 7. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
|
||||
* You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
||||
*
|
||||
* 8. `P+` tokens do not have a defined priority since they are merely aliases to other tokens based
|
||||
@@ -322,6 +311,7 @@ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
||||
* Time value of Date: http://es5.github.io/#x15.9.1.1
|
||||
*
|
||||
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
||||
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
||||
*
|
||||
* @param dateStr - The string to parse
|
||||
* @param formatStr - The string of tokens
|
||||
@@ -352,10 +342,10 @@ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
||||
* })
|
||||
* //=> Sun Feb 28 2010 00:00:00
|
||||
*/
|
||||
function parse(dateStr, formatStr, referenceDate, options) {
|
||||
const defaultOptions = (0, _index2.getDefaultOptions)();
|
||||
const locale =
|
||||
options?.locale ?? defaultOptions.locale ?? _index3.defaultLocale;
|
||||
export function parse(dateStr, formatStr, referenceDate, options) {
|
||||
const invalidDate = () => constructFrom(options?.in || referenceDate, NaN);
|
||||
const defaultOptions = getDefaultOptions();
|
||||
const locale = options?.locale ?? defaultOptions.locale ?? defaultLocale;
|
||||
|
||||
const firstWeekContainsDate =
|
||||
options?.firstWeekContainsDate ??
|
||||
@@ -371,13 +361,8 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
defaultOptions.locale?.options?.weekStartsOn ??
|
||||
0;
|
||||
|
||||
if (formatStr === "") {
|
||||
if (dateStr === "") {
|
||||
return (0, _index4.toDate)(referenceDate);
|
||||
} else {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
}
|
||||
}
|
||||
if (!formatStr)
|
||||
return dateStr ? invalidDate() : toDate(referenceDate, options?.in);
|
||||
|
||||
const subFnOptions = {
|
||||
firstWeekContainsDate,
|
||||
@@ -385,15 +370,16 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
locale,
|
||||
};
|
||||
|
||||
// If timezone isn't specified, it will be set to the system timezone
|
||||
const setters = [new _Setter.DateToSystemTimezoneSetter()];
|
||||
// If timezone isn't specified, it will try to use the context or
|
||||
// the reference date and fallback to the system time zone.
|
||||
const setters = [new DateTimezoneSetter(options?.in, referenceDate)];
|
||||
|
||||
const tokens = formatStr
|
||||
.match(longFormattingTokensRegExp)
|
||||
.map((substring) => {
|
||||
const firstCharacter = substring[0];
|
||||
if (firstCharacter in _index5.longFormatters) {
|
||||
const longFormatter = _index5.longFormatters[firstCharacter];
|
||||
if (firstCharacter in longFormatters) {
|
||||
const longFormatter = longFormatters[firstCharacter];
|
||||
return longFormatter(substring, locale.formatLong);
|
||||
}
|
||||
return substring;
|
||||
@@ -406,19 +392,19 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
for (let token of tokens) {
|
||||
if (
|
||||
!options?.useAdditionalWeekYearTokens &&
|
||||
(0, _index6.isProtectedWeekYearToken)(token)
|
||||
isProtectedWeekYearToken(token)
|
||||
) {
|
||||
(0, _index6.warnOrThrowProtectedError)(token, formatStr, dateStr);
|
||||
warnOrThrowProtectedError(token, formatStr, dateStr);
|
||||
}
|
||||
if (
|
||||
!options?.useAdditionalDayOfYearTokens &&
|
||||
(0, _index6.isProtectedDayOfYearToken)(token)
|
||||
isProtectedDayOfYearToken(token)
|
||||
) {
|
||||
(0, _index6.warnOrThrowProtectedError)(token, formatStr, dateStr);
|
||||
warnOrThrowProtectedError(token, formatStr, dateStr);
|
||||
}
|
||||
|
||||
const firstCharacter = token[0];
|
||||
const parser = _index7.parsers[firstCharacter];
|
||||
const parser = parsers[firstCharacter];
|
||||
if (parser) {
|
||||
const { incompatibleTokens } = parser;
|
||||
if (Array.isArray(incompatibleTokens)) {
|
||||
@@ -448,7 +434,7 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
);
|
||||
|
||||
if (!parseResult) {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
return invalidDate();
|
||||
}
|
||||
|
||||
setters.push(parseResult.setter);
|
||||
@@ -474,14 +460,14 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
if (dateStr.indexOf(token) === 0) {
|
||||
dateStr = dateStr.slice(token.length);
|
||||
} else {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
return invalidDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the remaining input contains something other than whitespace
|
||||
if (dateStr.length > 0 && notWhitespaceRegExp.test(dateStr)) {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
return invalidDate();
|
||||
}
|
||||
|
||||
const uniquePrioritySetters = setters
|
||||
@@ -495,16 +481,14 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
)
|
||||
.map((setterArray) => setterArray[0]);
|
||||
|
||||
let date = (0, _index4.toDate)(referenceDate);
|
||||
let date = toDate(referenceDate, options?.in);
|
||||
|
||||
if (isNaN(date.getTime())) {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
}
|
||||
if (isNaN(+date)) return invalidDate();
|
||||
|
||||
const flags = {};
|
||||
for (const setter of uniquePrioritySetters) {
|
||||
if (!setter.validate(date, subFnOptions)) {
|
||||
return (0, _index.constructFrom)(referenceDate, NaN);
|
||||
return invalidDate();
|
||||
}
|
||||
|
||||
const result = setter.set(date, flags, subFnOptions);
|
||||
@@ -518,9 +502,12 @@ function parse(dateStr, formatStr, referenceDate, options) {
|
||||
}
|
||||
}
|
||||
|
||||
return (0, _index.constructFrom)(referenceDate, date);
|
||||
return date;
|
||||
}
|
||||
|
||||
function cleanEscapedString(input) {
|
||||
return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default parse;
|
||||
|
||||
Reference in New Issue
Block a user