init 3
This commit is contained in:
34
node_modules/date-fns/parse/_lib/Parser.d.ts
generated
vendored
Normal file
34
node_modules/date-fns/parse/_lib/Parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { Match } from "../../locale/types.js";
|
||||
import { ValueSetter } from "./Setter.js";
|
||||
import type { ParseFlags, ParseResult, ParserOptions } from "./types.js";
|
||||
export declare abstract class Parser<Value> {
|
||||
abstract incompatibleTokens: string[] | "*";
|
||||
abstract priority: number;
|
||||
subPriority?: number;
|
||||
run(
|
||||
dateString: string,
|
||||
token: string,
|
||||
match: Match,
|
||||
options: ParserOptions,
|
||||
): {
|
||||
setter: ValueSetter<Value>;
|
||||
rest: string;
|
||||
} | null;
|
||||
protected abstract parse(
|
||||
dateString: string,
|
||||
token: string,
|
||||
match: Match,
|
||||
options: ParserOptions,
|
||||
): ParseResult<Value>;
|
||||
protected validate<DateType extends Date>(
|
||||
_utcDate: DateType,
|
||||
_value: Value,
|
||||
_options: ParserOptions,
|
||||
): boolean;
|
||||
protected abstract set<DateType extends Date>(
|
||||
date: DateType,
|
||||
flags: ParseFlags,
|
||||
value: Value,
|
||||
options: ParserOptions,
|
||||
): DateType | [DateType, ParseFlags];
|
||||
}
|
||||
31
node_modules/date-fns/parse/_lib/constants.mjs
generated
vendored
Normal file
31
node_modules/date-fns/parse/_lib/constants.mjs
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
export const numericPatterns = {
|
||||
month: /^(1[0-2]|0?\d)/, // 0 to 12
|
||||
date: /^(3[0-1]|[0-2]?\d)/, // 0 to 31
|
||||
dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/, // 0 to 366
|
||||
week: /^(5[0-3]|[0-4]?\d)/, // 0 to 53
|
||||
hour23h: /^(2[0-3]|[0-1]?\d)/, // 0 to 23
|
||||
hour24h: /^(2[0-4]|[0-1]?\d)/, // 0 to 24
|
||||
hour11h: /^(1[0-1]|0?\d)/, // 0 to 11
|
||||
hour12h: /^(1[0-2]|0?\d)/, // 0 to 12
|
||||
minute: /^[0-5]?\d/, // 0 to 59
|
||||
second: /^[0-5]?\d/, // 0 to 59
|
||||
|
||||
singleDigit: /^\d/, // 0 to 9
|
||||
twoDigits: /^\d{1,2}/, // 0 to 99
|
||||
threeDigits: /^\d{1,3}/, // 0 to 999
|
||||
fourDigits: /^\d{1,4}/, // 0 to 9999
|
||||
|
||||
anyDigitsSigned: /^-?\d+/,
|
||||
singleDigitSigned: /^-?\d/, // 0 to 9, -0 to -9
|
||||
twoDigitsSigned: /^-?\d{1,2}/, // 0 to 99, -0 to -99
|
||||
threeDigitsSigned: /^-?\d{1,3}/, // 0 to 999, -0 to -999
|
||||
fourDigitsSigned: /^-?\d{1,4}/, // 0 to 9999, -0 to -9999
|
||||
};
|
||||
|
||||
export const timezonePatterns = {
|
||||
basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
|
||||
basic: /^([+-])(\d{2})(\d{2})|Z/,
|
||||
basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
|
||||
extended: /^([+-])(\d{2}):(\d{2})|Z/,
|
||||
extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/,
|
||||
};
|
||||
17
node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.d.mts
generated
vendored
Normal file
17
node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.d.mts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { LocaleDayPeriod, Match } from "../../../locale/types.js";
|
||||
import { Parser } from "../Parser.js";
|
||||
import type { ParseFlags, ParseResult } from "../types.js";
|
||||
export declare class DayPeriodParser extends Parser<LocaleDayPeriod> {
|
||||
priority: number;
|
||||
parse(
|
||||
dateString: string,
|
||||
token: string,
|
||||
match: Match,
|
||||
): ParseResult<LocaleDayPeriod>;
|
||||
set<DateType extends Date>(
|
||||
date: DateType,
|
||||
_flags: ParseFlags,
|
||||
value: LocaleDayPeriod,
|
||||
): DateType;
|
||||
incompatibleTokens: string[];
|
||||
}
|
||||
39
node_modules/date-fns/parse/_lib/parsers/EraParser.mjs
generated
vendored
Normal file
39
node_modules/date-fns/parse/_lib/parsers/EraParser.mjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Parser } from "../Parser.mjs";
|
||||
|
||||
export class EraParser extends Parser {
|
||||
priority = 140;
|
||||
|
||||
parse(dateString, token, match) {
|
||||
switch (token) {
|
||||
// AD, BC
|
||||
case "G":
|
||||
case "GG":
|
||||
case "GGG":
|
||||
return (
|
||||
match.era(dateString, { width: "abbreviated" }) ||
|
||||
match.era(dateString, { width: "narrow" })
|
||||
);
|
||||
|
||||
// A, B
|
||||
case "GGGGG":
|
||||
return match.era(dateString, { width: "narrow" });
|
||||
// Anno Domini, Before Christ
|
||||
case "GGGG":
|
||||
default:
|
||||
return (
|
||||
match.era(dateString, { width: "wide" }) ||
|
||||
match.era(dateString, { width: "abbreviated" }) ||
|
||||
match.era(dateString, { width: "narrow" })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
set(date, flags, value) {
|
||||
flags.era = value;
|
||||
date.setFullYear(value, 0, 1);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
incompatibleTokens = ["R", "u", "t", "T"];
|
||||
}
|
||||
12
node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.d.mts
generated
vendored
Normal file
12
node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.d.mts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Parser } from "../Parser.js";
|
||||
import type { ParseFlags, ParseResult } from "../types.js";
|
||||
export declare class FractionOfSecondParser extends Parser<number> {
|
||||
priority: number;
|
||||
parse(dateString: string, token: string): ParseResult<number>;
|
||||
set<DateType extends Date>(
|
||||
date: DateType,
|
||||
_flags: ParseFlags,
|
||||
value: number,
|
||||
): DateType;
|
||||
incompatibleTokens: string[];
|
||||
}
|
||||
41
node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js
generated
vendored
Normal file
41
node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
exports.Hour0To11Parser = void 0;
|
||||
var _constants = require("../constants.js");
|
||||
var _Parser = require("../Parser.js");
|
||||
|
||||
var _utils = require("../utils.js");
|
||||
|
||||
class Hour0To11Parser extends _Parser.Parser {
|
||||
priority = 70;
|
||||
|
||||
parse(dateString, token, match) {
|
||||
switch (token) {
|
||||
case "K":
|
||||
return (0, _utils.parseNumericPattern)(
|
||||
_constants.numericPatterns.hour11h,
|
||||
dateString,
|
||||
);
|
||||
case "Ko":
|
||||
return match.ordinalNumber(dateString, { unit: "hour" });
|
||||
default:
|
||||
return (0, _utils.parseNDigits)(token.length, dateString);
|
||||
}
|
||||
}
|
||||
|
||||
validate(_date, value) {
|
||||
return value >= 0 && value <= 11;
|
||||
}
|
||||
|
||||
set(date, _flags, value) {
|
||||
const isPM = date.getHours() >= 12;
|
||||
if (isPM && value < 12) {
|
||||
date.setHours(value + 12, 0, 0, 0);
|
||||
} else {
|
||||
date.setHours(value, 0, 0, 0);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
incompatibleTokens = ["h", "H", "k", "t", "T"];
|
||||
}
|
||||
exports.Hour0To11Parser = Hour0To11Parser;
|
||||
14
node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.d.ts
generated
vendored
Normal file
14
node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { Match } from "../../../locale/types.js";
|
||||
import { Parser } from "../Parser.js";
|
||||
import type { ParseFlags, ParseResult } from "../types.js";
|
||||
export declare class Hour1To24Parser extends Parser<number> {
|
||||
priority: number;
|
||||
parse(dateString: string, token: string, match: Match): ParseResult<number>;
|
||||
validate<DateType extends Date>(_date: DateType, value: number): boolean;
|
||||
set<DateType extends Date>(
|
||||
date: DateType,
|
||||
_flags: ParseFlags,
|
||||
value: number,
|
||||
): DateType;
|
||||
incompatibleTokens: string[];
|
||||
}
|
||||
45
node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.mjs
generated
vendored
Normal file
45
node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.mjs
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import { constructFrom } from "../../../constructFrom.mjs";
|
||||
import { getTimezoneOffsetInMilliseconds } from "../../../_lib/getTimezoneOffsetInMilliseconds.mjs";
|
||||
import { timezonePatterns } from "../constants.mjs";
|
||||
import { Parser } from "../Parser.mjs";
|
||||
import { parseTimezonePattern } from "../utils.mjs";
|
||||
|
||||
// Timezone (ISO-8601)
|
||||
export class ISOTimezoneParser extends Parser {
|
||||
priority = 10;
|
||||
|
||||
parse(dateString, token) {
|
||||
switch (token) {
|
||||
case "x":
|
||||
return parseTimezonePattern(
|
||||
timezonePatterns.basicOptionalMinutes,
|
||||
dateString,
|
||||
);
|
||||
case "xx":
|
||||
return parseTimezonePattern(timezonePatterns.basic, dateString);
|
||||
case "xxxx":
|
||||
return parseTimezonePattern(
|
||||
timezonePatterns.basicOptionalSeconds,
|
||||
dateString,
|
||||
);
|
||||
case "xxxxx":
|
||||
return parseTimezonePattern(
|
||||
timezonePatterns.extendedOptionalSeconds,
|
||||
dateString,
|
||||
);
|
||||
case "xxx":
|
||||
default:
|
||||
return parseTimezonePattern(timezonePatterns.extended, dateString);
|
||||
}
|
||||
}
|
||||
|
||||
set(date, flags, value) {
|
||||
if (flags.timestampIsSet) return date;
|
||||
return constructFrom(
|
||||
date,
|
||||
date.getTime() - getTimezoneOffsetInMilliseconds(date) - value,
|
||||
);
|
||||
}
|
||||
|
||||
incompatibleTokens = ["t", "T", "X"];
|
||||
}
|
||||
23
node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.d.ts
generated
vendored
Normal file
23
node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Match } from "../../../locale/types.js";
|
||||
import { Parser } from "../Parser.js";
|
||||
import type { ParseFlags, ParseResult, ParserOptions } from "../types.js";
|
||||
import type { YearParserValue } from "./YearParser.js";
|
||||
export declare class LocalWeekYearParser extends Parser<YearParserValue> {
|
||||
priority: number;
|
||||
parse(
|
||||
dateString: string,
|
||||
token: string,
|
||||
match: Match,
|
||||
): ParseResult<YearParserValue>;
|
||||
validate<DateType extends Date>(
|
||||
_date: DateType,
|
||||
value: YearParserValue,
|
||||
): boolean;
|
||||
set<DateType extends Date>(
|
||||
date: DateType,
|
||||
flags: ParseFlags,
|
||||
value: YearParserValue,
|
||||
options: ParserOptions,
|
||||
): DateType;
|
||||
incompatibleTokens: string[];
|
||||
}
|
||||
94
node_modules/date-fns/parse/_lib/parsers/MonthParser.js
generated
vendored
Normal file
94
node_modules/date-fns/parse/_lib/parsers/MonthParser.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
exports.MonthParser = void 0;
|
||||
var _constants = require("../constants.js");
|
||||
var _Parser = require("../Parser.js");
|
||||
|
||||
var _utils = require("../utils.js");
|
||||
|
||||
class MonthParser extends _Parser.Parser {
|
||||
incompatibleTokens = [
|
||||
"Y",
|
||||
"R",
|
||||
"q",
|
||||
"Q",
|
||||
"L",
|
||||
"w",
|
||||
"I",
|
||||
"D",
|
||||
"i",
|
||||
"e",
|
||||
"c",
|
||||
"t",
|
||||
"T",
|
||||
];
|
||||
|
||||
priority = 110;
|
||||
|
||||
parse(dateString, token, match) {
|
||||
const valueCallback = (value) => value - 1;
|
||||
|
||||
switch (token) {
|
||||
// 1, 2, ..., 12
|
||||
case "M":
|
||||
return (0, _utils.mapValue)(
|
||||
(0, _utils.parseNumericPattern)(
|
||||
_constants.numericPatterns.month,
|
||||
dateString,
|
||||
),
|
||||
valueCallback,
|
||||
);
|
||||
// 01, 02, ..., 12
|
||||
case "MM":
|
||||
return (0, _utils.mapValue)(
|
||||
(0, _utils.parseNDigits)(2, dateString),
|
||||
valueCallback,
|
||||
);
|
||||
// 1st, 2nd, ..., 12th
|
||||
case "Mo":
|
||||
return (0, _utils.mapValue)(
|
||||
match.ordinalNumber(dateString, {
|
||||
unit: "month",
|
||||
}),
|
||||
valueCallback,
|
||||
);
|
||||
// Jan, Feb, ..., Dec
|
||||
case "MMM":
|
||||
return (
|
||||
match.month(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
}) ||
|
||||
match.month(dateString, { width: "narrow", context: "formatting" })
|
||||
);
|
||||
|
||||
// J, F, ..., D
|
||||
case "MMMMM":
|
||||
return match.month(dateString, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// January, February, ..., December
|
||||
case "MMMM":
|
||||
default:
|
||||
return (
|
||||
match.month(dateString, { width: "wide", context: "formatting" }) ||
|
||||
match.month(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
}) ||
|
||||
match.month(dateString, { width: "narrow", context: "formatting" })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
validate(_date, value) {
|
||||
return value >= 0 && value <= 11;
|
||||
}
|
||||
|
||||
set(date, _flags, value) {
|
||||
date.setMonth(value, 1);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
}
|
||||
exports.MonthParser = MonthParser;
|
||||
85
node_modules/date-fns/parse/_lib/parsers/QuarterParser.js
generated
vendored
Normal file
85
node_modules/date-fns/parse/_lib/parsers/QuarterParser.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
exports.QuarterParser = void 0;
|
||||
var _Parser = require("../Parser.js");
|
||||
|
||||
var _utils = require("../utils.js");
|
||||
|
||||
class QuarterParser extends _Parser.Parser {
|
||||
priority = 120;
|
||||
|
||||
parse(dateString, token, match) {
|
||||
switch (token) {
|
||||
// 1, 2, 3, 4
|
||||
case "Q":
|
||||
case "QQ": // 01, 02, 03, 04
|
||||
return (0, _utils.parseNDigits)(token.length, dateString);
|
||||
// 1st, 2nd, 3rd, 4th
|
||||
case "Qo":
|
||||
return match.ordinalNumber(dateString, { unit: "quarter" });
|
||||
// Q1, Q2, Q3, Q4
|
||||
case "QQQ":
|
||||
return (
|
||||
match.quarter(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
}) ||
|
||||
match.quarter(dateString, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
})
|
||||
);
|
||||
|
||||
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
||||
case "QQQQQ":
|
||||
return match.quarter(dateString, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// 1st quarter, 2nd quarter, ...
|
||||
case "QQQQ":
|
||||
default:
|
||||
return (
|
||||
match.quarter(dateString, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
}) ||
|
||||
match.quarter(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
}) ||
|
||||
match.quarter(dateString, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
validate(_date, value) {
|
||||
return value >= 1 && value <= 4;
|
||||
}
|
||||
|
||||
set(date, _flags, value) {
|
||||
date.setMonth((value - 1) * 3, 1);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
incompatibleTokens = [
|
||||
"Y",
|
||||
"R",
|
||||
"q",
|
||||
"M",
|
||||
"L",
|
||||
"w",
|
||||
"I",
|
||||
"d",
|
||||
"D",
|
||||
"i",
|
||||
"e",
|
||||
"c",
|
||||
"t",
|
||||
"T",
|
||||
];
|
||||
}
|
||||
exports.QuarterParser = QuarterParser;
|
||||
95
node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.mjs
generated
vendored
Normal file
95
node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.mjs
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { setDay } from "../../../setDay.mjs";
|
||||
import { Parser } from "../Parser.mjs";
|
||||
import { mapValue, parseNDigits } from "../utils.mjs";
|
||||
|
||||
// Stand-alone local day of week
|
||||
export class StandAloneLocalDayParser extends Parser {
|
||||
priority = 90;
|
||||
|
||||
parse(dateString, token, match, options) {
|
||||
const valueCallback = (value) => {
|
||||
// We want here floor instead of trunc, so we get -7 for value 0 instead of 0
|
||||
const wholeWeekDays = Math.floor((value - 1) / 7) * 7;
|
||||
return ((value + options.weekStartsOn + 6) % 7) + wholeWeekDays;
|
||||
};
|
||||
|
||||
switch (token) {
|
||||
// 3
|
||||
case "c":
|
||||
case "cc": // 03
|
||||
return mapValue(parseNDigits(token.length, dateString), valueCallback);
|
||||
// 3rd
|
||||
case "co":
|
||||
return mapValue(
|
||||
match.ordinalNumber(dateString, {
|
||||
unit: "day",
|
||||
}),
|
||||
valueCallback,
|
||||
);
|
||||
// Tue
|
||||
case "ccc":
|
||||
return (
|
||||
match.day(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
}) ||
|
||||
match.day(dateString, { width: "short", context: "standalone" }) ||
|
||||
match.day(dateString, { width: "narrow", context: "standalone" })
|
||||
);
|
||||
|
||||
// T
|
||||
case "ccccc":
|
||||
return match.day(dateString, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// Tu
|
||||
case "cccccc":
|
||||
return (
|
||||
match.day(dateString, { width: "short", context: "standalone" }) ||
|
||||
match.day(dateString, { width: "narrow", context: "standalone" })
|
||||
);
|
||||
|
||||
// Tuesday
|
||||
case "cccc":
|
||||
default:
|
||||
return (
|
||||
match.day(dateString, { width: "wide", context: "standalone" }) ||
|
||||
match.day(dateString, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
}) ||
|
||||
match.day(dateString, { width: "short", context: "standalone" }) ||
|
||||
match.day(dateString, { width: "narrow", context: "standalone" })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
validate(_date, value) {
|
||||
return value >= 0 && value <= 6;
|
||||
}
|
||||
|
||||
set(date, _flags, value, options) {
|
||||
date = setDay(date, value, options);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
incompatibleTokens = [
|
||||
"y",
|
||||
"R",
|
||||
"u",
|
||||
"q",
|
||||
"Q",
|
||||
"M",
|
||||
"L",
|
||||
"I",
|
||||
"d",
|
||||
"D",
|
||||
"E",
|
||||
"i",
|
||||
"e",
|
||||
"t",
|
||||
"T",
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user