diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-06-28 17:26:46 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-06-28 17:43:56 -0700 |
| commit | e4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch) | |
| tree | 06284a538a6008eca75051399e47db4e5d50301c /node_modules/date-fns/esm/parse | |
initial commit: scaffolding
Diffstat (limited to 'node_modules/date-fns/esm/parse')
41 files changed, 2919 insertions, 0 deletions
diff --git a/node_modules/date-fns/esm/parse/_lib/Parser.js b/node_modules/date-fns/esm/parse/_lib/Parser.js new file mode 100644 index 0000000..b9b2678 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/Parser.js @@ -0,0 +1,31 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { ValueSetter } from "./Setter.js"; +export var Parser = /*#__PURE__*/function () { + function Parser() { + _classCallCheck(this, Parser); + _defineProperty(this, "incompatibleTokens", void 0); + _defineProperty(this, "priority", void 0); + _defineProperty(this, "subPriority", void 0); + } + _createClass(Parser, [{ + key: "run", + value: function run(dateString, token, match, options) { + var result = this.parse(dateString, token, match, options); + if (!result) { + return null; + } + return { + setter: new ValueSetter(result.value, this.validate, this.set, this.priority, this.subPriority), + rest: result.rest + }; + } + }, { + key: "validate", + value: function validate(_utcDate, _value, _options) { + return true; + } + }]); + return Parser; +}();
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/Setter.js b/node_modules/date-fns/esm/parse/_lib/Setter.js new file mode 100644 index 0000000..b73bbcf --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/Setter.js @@ -0,0 +1,78 @@ +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +var TIMEZONE_UNIT_PRIORITY = 10; +export var Setter = /*#__PURE__*/function () { + function Setter() { + _classCallCheck(this, Setter); + _defineProperty(this, "priority", void 0); + _defineProperty(this, "subPriority", 0); + } + _createClass(Setter, [{ + key: "validate", + value: function validate(_utcDate, _options) { + return true; + } + }]); + return Setter; +}(); +export var ValueSetter = /*#__PURE__*/function (_Setter) { + _inherits(ValueSetter, _Setter); + var _super = _createSuper(ValueSetter); + function ValueSetter(value, validateValue, setValue, priority, subPriority) { + var _this; + _classCallCheck(this, ValueSetter); + _this = _super.call(this); + _this.value = value; + _this.validateValue = validateValue; + _this.setValue = setValue; + _this.priority = priority; + if (subPriority) { + _this.subPriority = subPriority; + } + return _this; + } + _createClass(ValueSetter, [{ + key: "validate", + value: function validate(utcDate, options) { + return this.validateValue(utcDate, this.value, options); + } + }, { + key: "set", + value: function set(utcDate, flags, options) { + return this.setValue(utcDate, flags, this.value, options); + } + }]); + return ValueSetter; +}(Setter); +export var DateToSystemTimezoneSetter = /*#__PURE__*/function (_Setter2) { + _inherits(DateToSystemTimezoneSetter, _Setter2); + var _super2 = _createSuper(DateToSystemTimezoneSetter); + function DateToSystemTimezoneSetter() { + var _this2; + _classCallCheck(this, DateToSystemTimezoneSetter); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this2 = _super2.call.apply(_super2, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this2), "priority", TIMEZONE_UNIT_PRIORITY); + _defineProperty(_assertThisInitialized(_this2), "subPriority", -1); + return _this2; + } + _createClass(DateToSystemTimezoneSetter, [{ + key: "set", + value: function set(date, flags) { + if (flags.timestampIsSet) { + return date; + } + var convertedDate = new Date(0); + convertedDate.setFullYear(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); + convertedDate.setHours(date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds()); + return convertedDate; + } + }]); + return DateToSystemTimezoneSetter; +}(Setter);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/constants.js b/node_modules/date-fns/esm/parse/_lib/constants.js new file mode 100644 index 0000000..b095afa --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/constants.js @@ -0,0 +1,48 @@ +export var 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 var 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/ +};
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js new file mode 100644 index 0000000..0ce4373 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js @@ -0,0 +1,64 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { dayPeriodEnumToHours } from "../utils.js"; +export var AMPMMidnightParser = /*#__PURE__*/function (_Parser) { + _inherits(AMPMMidnightParser, _Parser); + var _super = _createSuper(AMPMMidnightParser); + function AMPMMidnightParser() { + var _this; + _classCallCheck(this, AMPMMidnightParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 80); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'B', 'H', 'k', 't', 'T']); + return _this; + } + _createClass(AMPMMidnightParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'b': + case 'bb': + case 'bbb': + return match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'bbbbb': + return match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'bbbb': + default: + return match.dayPeriod(dateString, { + width: 'wide', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + } + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0); + return date; + } + }]); + return AMPMMidnightParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js new file mode 100644 index 0000000..1e89dac --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js @@ -0,0 +1,64 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { dayPeriodEnumToHours } from "../utils.js"; +export var AMPMParser = /*#__PURE__*/function (_Parser) { + _inherits(AMPMParser, _Parser); + var _super = _createSuper(AMPMParser); + function AMPMParser() { + var _this; + _classCallCheck(this, AMPMParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 80); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['b', 'B', 'H', 'k', 't', 'T']); + return _this; + } + _createClass(AMPMParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'a': + case 'aa': + case 'aaa': + return match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'aaaaa': + return match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'aaaa': + default: + return match.dayPeriod(dateString, { + width: 'wide', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + } + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0); + return date; + } + }]); + return AMPMParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js new file mode 100644 index 0000000..6e94944 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js @@ -0,0 +1,64 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { isLeapYearIndex, parseNDigits, parseNumericPattern } from "../utils.js"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +// Day of the month +export var DateParser = /*#__PURE__*/function (_Parser) { + _inherits(DateParser, _Parser); + var _super = _createSuper(DateParser); + function DateParser() { + var _this; + _classCallCheck(this, DateParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "subPriority", 1); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(DateParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'd': + return parseNumericPattern(numericPatterns.date, dateString); + case 'do': + return match.ordinalNumber(dateString, { + unit: 'date' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(date, value) { + var year = date.getUTCFullYear(); + var isLeapYear = isLeapYearIndex(year); + var month = date.getUTCMonth(); + if (isLeapYear) { + return value >= 1 && value <= DAYS_IN_MONTH_LEAP_YEAR[month]; + } else { + return value >= 1 && value <= DAYS_IN_MONTH[month]; + } + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCDate(value); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return DateParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js new file mode 100644 index 0000000..0a0ef45 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js @@ -0,0 +1,60 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits, isLeapYearIndex } from "../utils.js"; +export var DayOfYearParser = /*#__PURE__*/function (_Parser) { + _inherits(DayOfYearParser, _Parser); + var _super = _createSuper(DayOfYearParser); + function DayOfYearParser() { + var _this; + _classCallCheck(this, DayOfYearParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "subpriority", 1); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'L', 'w', 'I', 'd', 'E', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(DayOfYearParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'D': + case 'DD': + return parseNumericPattern(numericPatterns.dayOfYear, dateString); + case 'Do': + return match.ordinalNumber(dateString, { + unit: 'date' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(date, value) { + var year = date.getUTCFullYear(); + var isLeapYear = isLeapYearIndex(year); + if (isLeapYear) { + return value >= 1 && value <= 366; + } else { + return value >= 1 && value <= 365; + } + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMonth(0, value); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return DayOfYearParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js new file mode 100644 index 0000000..ad8a70e --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js @@ -0,0 +1,88 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import setUTCDay from "../../../_lib/setUTCDay/index.js"; // Day of week +export var DayParser = /*#__PURE__*/function (_Parser) { + _inherits(DayParser, _Parser); + var _super = _createSuper(DayParser); + function DayParser() { + var _this; + _classCallCheck(this, DayParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['D', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(DayParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + // Tue + case 'E': + case 'EE': + case 'EEE': + return match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // T + case 'EEEEE': + return match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // Tu + case 'EEEEEE': + return match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // Tuesday + case 'EEEE': + default: + return match.day(dateString, { + width: 'wide', + context: 'formatting' + }) || match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 6; + } + }, { + key: "set", + value: function set(date, _flags, value, options) { + date = setUTCDay(date, value, options); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return DayParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js new file mode 100644 index 0000000..ec4c4d8 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js @@ -0,0 +1,64 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { dayPeriodEnumToHours } from "../utils.js"; // in the morning, in the afternoon, in the evening, at night +export var DayPeriodParser = /*#__PURE__*/function (_Parser) { + _inherits(DayPeriodParser, _Parser); + var _super = _createSuper(DayPeriodParser); + function DayPeriodParser() { + var _this; + _classCallCheck(this, DayPeriodParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 80); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 't', 'T']); + return _this; + } + _createClass(DayPeriodParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'B': + case 'BB': + case 'BBB': + return match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'BBBBB': + return match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + case 'BBBB': + default: + return match.dayPeriod(dateString, { + width: 'wide', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.dayPeriod(dateString, { + width: 'narrow', + context: 'formatting' + }); + } + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0); + return date; + } + }]); + return DayPeriodParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js new file mode 100644 index 0000000..8a5954d --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js @@ -0,0 +1,62 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +export var EraParser = /*#__PURE__*/function (_Parser) { + _inherits(EraParser, _Parser); + var _super = _createSuper(EraParser); + function EraParser() { + var _this; + _classCallCheck(this, EraParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 140); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['R', 'u', 't', 'T']); + return _this; + } + _createClass(EraParser, [{ + key: "parse", + value: function 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' + }); + } + } + }, { + key: "set", + value: function set(date, flags, value) { + flags.era = value; + date.setUTCFullYear(value, 0, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return EraParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js new file mode 100644 index 0000000..8bf8dcd --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js @@ -0,0 +1,40 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseNDigitsSigned } from "../utils.js"; +export var ExtendedYearParser = /*#__PURE__*/function (_Parser) { + _inherits(ExtendedYearParser, _Parser); + var _super = _createSuper(ExtendedYearParser); + function ExtendedYearParser() { + var _this; + _classCallCheck(this, ExtendedYearParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 130); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['G', 'y', 'Y', 'R', 'w', 'I', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(ExtendedYearParser, [{ + key: "parse", + value: function parse(dateString, token) { + if (token === 'u') { + return parseNDigitsSigned(4, dateString); + } + return parseNDigitsSigned(token.length, dateString); + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCFullYear(value, 0, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return ExtendedYearParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js new file mode 100644 index 0000000..c5b7b9b --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js @@ -0,0 +1,39 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { mapValue, parseNDigits } from "../utils.js"; +export var FractionOfSecondParser = /*#__PURE__*/function (_Parser) { + _inherits(FractionOfSecondParser, _Parser); + var _super = _createSuper(FractionOfSecondParser); + function FractionOfSecondParser() { + var _this; + _classCallCheck(this, FractionOfSecondParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 30); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']); + return _this; + } + _createClass(FractionOfSecondParser, [{ + key: "parse", + value: function parse(dateString, token) { + var valueCallback = function valueCallback(value) { + return Math.floor(value * Math.pow(10, -token.length + 3)); + }; + return mapValue(parseNDigits(token.length, dateString), valueCallback); + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMilliseconds(value); + return date; + } + }]); + return FractionOfSecondParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js b/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js new file mode 100644 index 0000000..57af2ba --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js @@ -0,0 +1,56 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var Hour0To11Parser = /*#__PURE__*/function (_Parser) { + _inherits(Hour0To11Parser, _Parser); + var _super = _createSuper(Hour0To11Parser); + function Hour0To11Parser() { + var _this; + _classCallCheck(this, Hour0To11Parser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 70); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['h', 'H', 'k', 't', 'T']); + return _this; + } + _createClass(Hour0To11Parser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'K': + return parseNumericPattern(numericPatterns.hour11h, dateString); + case 'Ko': + return match.ordinalNumber(dateString, { + unit: 'hour' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 11; + } + }, { + key: "set", + value: function set(date, _flags, value) { + var isPM = date.getUTCHours() >= 12; + if (isPM && value < 12) { + date.setUTCHours(value + 12, 0, 0, 0); + } else { + date.setUTCHours(value, 0, 0, 0); + } + return date; + } + }]); + return Hour0To11Parser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js b/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js new file mode 100644 index 0000000..d77b321 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js @@ -0,0 +1,51 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var Hour0to23Parser = /*#__PURE__*/function (_Parser) { + _inherits(Hour0to23Parser, _Parser); + var _super = _createSuper(Hour0to23Parser); + function Hour0to23Parser() { + var _this; + _classCallCheck(this, Hour0to23Parser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 70); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 'h', 'K', 'k', 't', 'T']); + return _this; + } + _createClass(Hour0to23Parser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'H': + return parseNumericPattern(numericPatterns.hour23h, dateString); + case 'Ho': + return match.ordinalNumber(dateString, { + unit: 'hour' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 23; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCHours(value, 0, 0, 0); + return date; + } + }]); + return Hour0to23Parser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js b/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js new file mode 100644 index 0000000..f4f801b --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js @@ -0,0 +1,52 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var Hour1To24Parser = /*#__PURE__*/function (_Parser) { + _inherits(Hour1To24Parser, _Parser); + var _super = _createSuper(Hour1To24Parser); + function Hour1To24Parser() { + var _this; + _classCallCheck(this, Hour1To24Parser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 70); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 'h', 'H', 'K', 't', 'T']); + return _this; + } + _createClass(Hour1To24Parser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'k': + return parseNumericPattern(numericPatterns.hour24h, dateString); + case 'ko': + return match.ordinalNumber(dateString, { + unit: 'hour' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 24; + } + }, { + key: "set", + value: function set(date, _flags, value) { + var hours = value <= 24 ? value % 24 : value; + date.setUTCHours(hours, 0, 0, 0); + return date; + } + }]); + return Hour1To24Parser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js b/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js new file mode 100644 index 0000000..26f849f --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js @@ -0,0 +1,58 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var Hour1to12Parser = /*#__PURE__*/function (_Parser) { + _inherits(Hour1to12Parser, _Parser); + var _super = _createSuper(Hour1to12Parser); + function Hour1to12Parser() { + var _this; + _classCallCheck(this, Hour1to12Parser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 70); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['H', 'K', 'k', 't', 'T']); + return _this; + } + _createClass(Hour1to12Parser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'h': + return parseNumericPattern(numericPatterns.hour12h, dateString); + case 'ho': + return match.ordinalNumber(dateString, { + unit: 'hour' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 12; + } + }, { + key: "set", + value: function set(date, _flags, value) { + var isPM = date.getUTCHours() >= 12; + if (isPM && value < 12) { + date.setUTCHours(value + 12, 0, 0, 0); + } else if (!isPM && value === 12) { + date.setUTCHours(0, 0, 0, 0); + } else { + date.setUTCHours(value, 0, 0, 0); + } + return date; + } + }]); + return Hour1to12Parser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js new file mode 100644 index 0000000..ae1e5a8 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js @@ -0,0 +1,103 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { mapValue, parseNDigits } from "../utils.js"; +import setUTCISODay from "../../../_lib/setUTCISODay/index.js"; // ISO day of week +export var ISODayParser = /*#__PURE__*/function (_Parser) { + _inherits(ISODayParser, _Parser); + var _super = _createSuper(ISODayParser); + function ISODayParser() { + var _this; + _classCallCheck(this, ISODayParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'E', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(ISODayParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + var valueCallback = function valueCallback(value) { + if (value === 0) { + return 7; + } + return value; + }; + switch (token) { + // 2 + case 'i': + case 'ii': + // 02 + return parseNDigits(token.length, dateString); + // 2nd + case 'io': + return match.ordinalNumber(dateString, { + unit: 'day' + }); + // Tue + case 'iii': + return mapValue(match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }), valueCallback); + // T + case 'iiiii': + return mapValue(match.day(dateString, { + width: 'narrow', + context: 'formatting' + }), valueCallback); + // Tu + case 'iiiiii': + return mapValue(match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }), valueCallback); + // Tuesday + case 'iiii': + default: + return mapValue(match.day(dateString, { + width: 'wide', + context: 'formatting' + }) || match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }), valueCallback); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 7; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date = setUTCISODay(date, value); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return ISODayParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js new file mode 100644 index 0000000..0f5f28a --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js @@ -0,0 +1,51 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { timezonePatterns } from "../constants.js"; +import { parseTimezonePattern } from "../utils.js"; // Timezone (ISO-8601) +export var ISOTimezoneParser = /*#__PURE__*/function (_Parser) { + _inherits(ISOTimezoneParser, _Parser); + var _super = _createSuper(ISOTimezoneParser); + function ISOTimezoneParser() { + var _this; + _classCallCheck(this, ISOTimezoneParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 10); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T', 'X']); + return _this; + } + _createClass(ISOTimezoneParser, [{ + key: "parse", + value: function 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); + } + } + }, { + key: "set", + value: function set(date, flags, value) { + if (flags.timestampIsSet) { + return date; + } + return new Date(date.getTime() - value); + } + }]); + return ISOTimezoneParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js new file mode 100644 index 0000000..c214d84 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js @@ -0,0 +1,51 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { timezonePatterns } from "../constants.js"; +import { parseTimezonePattern } from "../utils.js"; // Timezone (ISO-8601. +00:00 is `'Z'`) +export var ISOTimezoneWithZParser = /*#__PURE__*/function (_Parser) { + _inherits(ISOTimezoneWithZParser, _Parser); + var _super = _createSuper(ISOTimezoneWithZParser); + function ISOTimezoneWithZParser() { + var _this; + _classCallCheck(this, ISOTimezoneWithZParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 10); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T', 'x']); + return _this; + } + _createClass(ISOTimezoneWithZParser, [{ + key: "parse", + value: function 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); + } + } + }, { + key: "set", + value: function set(date, flags, value) { + if (flags.timestampIsSet) { + return date; + } + return new Date(date.getTime() - value); + } + }]); + return ISOTimezoneWithZParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js new file mode 100644 index 0000000..2992a1b --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js @@ -0,0 +1,52 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +import setUTCISOWeek from "../../../_lib/setUTCISOWeek/index.js"; +import startOfUTCISOWeek from "../../../_lib/startOfUTCISOWeek/index.js"; // ISO week of year +export var ISOWeekParser = /*#__PURE__*/function (_Parser) { + _inherits(ISOWeekParser, _Parser); + var _super = _createSuper(ISOWeekParser); + function ISOWeekParser() { + var _this; + _classCallCheck(this, ISOWeekParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 100); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(ISOWeekParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'I': + return parseNumericPattern(numericPatterns.week, dateString); + case 'Io': + return match.ordinalNumber(dateString, { + unit: 'week' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 53; + } + }, { + key: "set", + value: function set(date, _flags, value) { + return startOfUTCISOWeek(setUTCISOWeek(date, value)); + } + }]); + return ISOWeekParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js new file mode 100644 index 0000000..c329a28 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js @@ -0,0 +1,42 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseNDigitsSigned } from "../utils.js"; +import startOfUTCISOWeek from "../../../_lib/startOfUTCISOWeek/index.js"; // ISO week-numbering year +export var ISOWeekYearParser = /*#__PURE__*/function (_Parser) { + _inherits(ISOWeekYearParser, _Parser); + var _super = _createSuper(ISOWeekYearParser); + function ISOWeekYearParser() { + var _this; + _classCallCheck(this, ISOWeekYearParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 130); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['G', 'y', 'Y', 'u', 'Q', 'q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(ISOWeekYearParser, [{ + key: "parse", + value: function parse(dateString, token) { + if (token === 'R') { + return parseNDigitsSigned(4, dateString); + } + return parseNDigitsSigned(token.length, dateString); + } + }, { + key: "set", + value: function set(_date, _flags, value) { + var firstWeekOfYear = new Date(0); + firstWeekOfYear.setUTCFullYear(value, 0, 4); + firstWeekOfYear.setUTCHours(0, 0, 0, 0); + return startOfUTCISOWeek(firstWeekOfYear); + } + }]); + return ISOWeekYearParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js new file mode 100644 index 0000000..4e5b700 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js @@ -0,0 +1,101 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { mapValue, parseNDigits } from "../utils.js"; +import setUTCDay from "../../../_lib/setUTCDay/index.js"; // Local day of week +export var LocalDayParser = /*#__PURE__*/function (_Parser) { + _inherits(LocalDayParser, _Parser); + var _super = _createSuper(LocalDayParser); + function LocalDayParser() { + var _this; + _classCallCheck(this, LocalDayParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'c', 't', 'T']); + return _this; + } + _createClass(LocalDayParser, [{ + key: "parse", + value: function parse(dateString, token, match, options) { + var valueCallback = function valueCallback(value) { + var wholeWeekDays = Math.floor((value - 1) / 7) * 7; + return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays; + }; + switch (token) { + // 3 + case 'e': + case 'ee': + // 03 + return mapValue(parseNDigits(token.length, dateString), valueCallback); + // 3rd + case 'eo': + return mapValue(match.ordinalNumber(dateString, { + unit: 'day' + }), valueCallback); + // Tue + case 'eee': + return match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // T + case 'eeeee': + return match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // Tu + case 'eeeeee': + return match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + // Tuesday + case 'eeee': + default: + return match.day(dateString, { + width: 'wide', + context: 'formatting' + }) || match.day(dateString, { + width: 'abbreviated', + context: 'formatting' + }) || match.day(dateString, { + width: 'short', + context: 'formatting' + }) || match.day(dateString, { + width: 'narrow', + context: 'formatting' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 6; + } + }, { + key: "set", + value: function set(date, _flags, value, options) { + date = setUTCDay(date, value, options); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return LocalDayParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js new file mode 100644 index 0000000..495c732 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js @@ -0,0 +1,52 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +import setUTCWeek from "../../../_lib/setUTCWeek/index.js"; +import startOfUTCWeek from "../../../_lib/startOfUTCWeek/index.js"; // Local week of year +export var LocalWeekParser = /*#__PURE__*/function (_Parser) { + _inherits(LocalWeekParser, _Parser); + var _super = _createSuper(LocalWeekParser); + function LocalWeekParser() { + var _this; + _classCallCheck(this, LocalWeekParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 100); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']); + return _this; + } + _createClass(LocalWeekParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'w': + return parseNumericPattern(numericPatterns.week, dateString); + case 'wo': + return match.ordinalNumber(dateString, { + unit: 'week' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 53; + } + }, { + key: "set", + value: function set(date, _flags, value, options) { + return startOfUTCWeek(setUTCWeek(date, value, options), options); + } + }]); + return LocalWeekParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js new file mode 100644 index 0000000..2b21916 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js @@ -0,0 +1,68 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseNDigits, normalizeTwoDigitYear, mapValue } from "../utils.js"; +import getUTCWeekYear from "../../../_lib/getUTCWeekYear/index.js"; +import startOfUTCWeek from "../../../_lib/startOfUTCWeek/index.js"; +// Local week-numbering year +export var LocalWeekYearParser = /*#__PURE__*/function (_Parser) { + _inherits(LocalWeekYearParser, _Parser); + var _super = _createSuper(LocalWeekYearParser); + function LocalWeekYearParser() { + var _this; + _classCallCheck(this, LocalWeekYearParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 130); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'Q', 'q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']); + return _this; + } + _createClass(LocalWeekYearParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + var valueCallback = function valueCallback(year) { + return { + year: year, + isTwoDigitYear: token === 'YY' + }; + }; + switch (token) { + case 'Y': + return mapValue(parseNDigits(4, dateString), valueCallback); + case 'Yo': + return mapValue(match.ordinalNumber(dateString, { + unit: 'year' + }), valueCallback); + default: + return mapValue(parseNDigits(token.length, dateString), valueCallback); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value.isTwoDigitYear || value.year > 0; + } + }, { + key: "set", + value: function set(date, flags, value, options) { + var currentYear = getUTCWeekYear(date, options); + if (value.isTwoDigitYear) { + var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear); + date.setUTCFullYear(normalizedTwoDigitYear, 0, options.firstWeekContainsDate); + date.setUTCHours(0, 0, 0, 0); + return startOfUTCWeek(date, options); + } + var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year; + date.setUTCFullYear(year, 0, options.firstWeekContainsDate); + date.setUTCHours(0, 0, 0, 0); + return startOfUTCWeek(date, options); + } + }]); + return LocalWeekYearParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js new file mode 100644 index 0000000..c27c59a --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js @@ -0,0 +1,51 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var MinuteParser = /*#__PURE__*/function (_Parser) { + _inherits(MinuteParser, _Parser); + var _super = _createSuper(MinuteParser); + function MinuteParser() { + var _this; + _classCallCheck(this, MinuteParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 60); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']); + return _this; + } + _createClass(MinuteParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 'm': + return parseNumericPattern(numericPatterns.minute, dateString); + case 'mo': + return match.ordinalNumber(dateString, { + unit: 'minute' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 59; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMinutes(value, 0, 0); + return date; + } + }]); + return MinuteParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js new file mode 100644 index 0000000..cf7ae58 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js @@ -0,0 +1,86 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { mapValue, parseNDigits, parseNumericPattern } from "../utils.js"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +export var MonthParser = /*#__PURE__*/function (_Parser) { + _inherits(MonthParser, _Parser); + var _super = _createSuper(MonthParser); + function MonthParser() { + var _this; + _classCallCheck(this, MonthParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'L', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']); + _defineProperty(_assertThisInitialized(_this), "priority", 110); + return _this; + } + _createClass(MonthParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + var valueCallback = function valueCallback(value) { + return value - 1; + }; + switch (token) { + // 1, 2, ..., 12 + case 'M': + return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback); + // 01, 02, ..., 12 + case 'MM': + return mapValue(parseNDigits(2, dateString), valueCallback); + // 1st, 2nd, ..., 12th + case 'Mo': + return 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' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 11; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMonth(value, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return MonthParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js new file mode 100644 index 0000000..f83972e --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js @@ -0,0 +1,81 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseNDigits } from "../utils.js"; +export var QuarterParser = /*#__PURE__*/function (_Parser) { + _inherits(QuarterParser, _Parser); + var _super = _createSuper(QuarterParser); + function QuarterParser() { + var _this; + _classCallCheck(this, QuarterParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 120); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(QuarterParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + // 1, 2, 3, 4 + case 'Q': + case 'QQ': + // 01, 02, 03, 04 + return 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' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 4; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMonth((value - 1) * 3, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return QuarterParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js new file mode 100644 index 0000000..7337ab7 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js @@ -0,0 +1,51 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits } from "../utils.js"; +export var SecondParser = /*#__PURE__*/function (_Parser) { + _inherits(SecondParser, _Parser); + var _super = _createSuper(SecondParser); + function SecondParser() { + var _this; + _classCallCheck(this, SecondParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 50); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']); + return _this; + } + _createClass(SecondParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + case 's': + return parseNumericPattern(numericPatterns.second, dateString); + case 'so': + return match.ordinalNumber(dateString, { + unit: 'second' + }); + default: + return parseNDigits(token.length, dateString); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 59; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCSeconds(value, 0); + return date; + } + }]); + return SecondParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js new file mode 100644 index 0000000..7b196d9 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js @@ -0,0 +1,101 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { mapValue, parseNDigits } from "../utils.js"; +import setUTCDay from "../../../_lib/setUTCDay/index.js"; // Stand-alone local day of week +export var StandAloneLocalDayParser = /*#__PURE__*/function (_Parser) { + _inherits(StandAloneLocalDayParser, _Parser); + var _super = _createSuper(StandAloneLocalDayParser); + function StandAloneLocalDayParser() { + var _this; + _classCallCheck(this, StandAloneLocalDayParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 90); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']); + return _this; + } + _createClass(StandAloneLocalDayParser, [{ + key: "parse", + value: function parse(dateString, token, match, options) { + var valueCallback = function valueCallback(value) { + var 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' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 6; + } + }, { + key: "set", + value: function set(date, _flags, value, options) { + date = setUTCDay(date, value, options); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return StandAloneLocalDayParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js new file mode 100644 index 0000000..de6a1b7 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js @@ -0,0 +1,86 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { numericPatterns } from "../constants.js"; +import { parseNumericPattern, parseNDigits, mapValue } from "../utils.js"; +export var StandAloneMonthParser = /*#__PURE__*/function (_Parser) { + _inherits(StandAloneMonthParser, _Parser); + var _super = _createSuper(StandAloneMonthParser); + function StandAloneMonthParser() { + var _this; + _classCallCheck(this, StandAloneMonthParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 110); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(StandAloneMonthParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + var valueCallback = function valueCallback(value) { + return value - 1; + }; + switch (token) { + // 1, 2, ..., 12 + case 'L': + return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback); + // 01, 02, ..., 12 + case 'LL': + return mapValue(parseNDigits(2, dateString), valueCallback); + // 1st, 2nd, ..., 12th + case 'Lo': + return mapValue(match.ordinalNumber(dateString, { + unit: 'month' + }), valueCallback); + // Jan, Feb, ..., Dec + case 'LLL': + return match.month(dateString, { + width: 'abbreviated', + context: 'standalone' + }) || match.month(dateString, { + width: 'narrow', + context: 'standalone' + }); + // J, F, ..., D + case 'LLLLL': + return match.month(dateString, { + width: 'narrow', + context: 'standalone' + }); + // January, February, ..., December + case 'LLLL': + default: + return match.month(dateString, { + width: 'wide', + context: 'standalone' + }) || match.month(dateString, { + width: 'abbreviated', + context: 'standalone' + }) || match.month(dateString, { + width: 'narrow', + context: 'standalone' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 0 && value <= 11; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMonth(value, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return StandAloneMonthParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js new file mode 100644 index 0000000..e823da3 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js @@ -0,0 +1,81 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseNDigits } from "../utils.js"; +export var StandAloneQuarterParser = /*#__PURE__*/function (_Parser) { + _inherits(StandAloneQuarterParser, _Parser); + var _super = _createSuper(StandAloneQuarterParser); + function StandAloneQuarterParser() { + var _this; + _classCallCheck(this, StandAloneQuarterParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 120); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(StandAloneQuarterParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + switch (token) { + // 1, 2, 3, 4 + case 'q': + case 'qq': + // 01, 02, 03, 04 + return 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: 'standalone' + }) || match.quarter(dateString, { + width: 'narrow', + context: 'standalone' + }); + // 1, 2, 3, 4 (narrow quarter; could be not numerical) + case 'qqqqq': + return match.quarter(dateString, { + width: 'narrow', + context: 'standalone' + }); + // 1st quarter, 2nd quarter, ... + case 'qqqq': + default: + return match.quarter(dateString, { + width: 'wide', + context: 'standalone' + }) || match.quarter(dateString, { + width: 'abbreviated', + context: 'standalone' + }) || match.quarter(dateString, { + width: 'narrow', + context: 'standalone' + }); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value >= 1 && value <= 4; + } + }, { + key: "set", + value: function set(date, _flags, value) { + date.setUTCMonth((value - 1) * 3, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return StandAloneQuarterParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js new file mode 100644 index 0000000..e91be0f --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js @@ -0,0 +1,37 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseAnyDigitsSigned } from "../utils.js"; +export var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) { + _inherits(TimestampMillisecondsParser, _Parser); + var _super = _createSuper(TimestampMillisecondsParser); + function TimestampMillisecondsParser() { + var _this; + _classCallCheck(this, TimestampMillisecondsParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 20); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", '*'); + return _this; + } + _createClass(TimestampMillisecondsParser, [{ + key: "parse", + value: function parse(dateString) { + return parseAnyDigitsSigned(dateString); + } + }, { + key: "set", + value: function set(_date, _flags, value) { + return [new Date(value), { + timestampIsSet: true + }]; + } + }]); + return TimestampMillisecondsParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js new file mode 100644 index 0000000..fc6a749 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js @@ -0,0 +1,37 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { parseAnyDigitsSigned } from "../utils.js"; +export var TimestampSecondsParser = /*#__PURE__*/function (_Parser) { + _inherits(TimestampSecondsParser, _Parser); + var _super = _createSuper(TimestampSecondsParser); + function TimestampSecondsParser() { + var _this; + _classCallCheck(this, TimestampSecondsParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 40); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", '*'); + return _this; + } + _createClass(TimestampSecondsParser, [{ + key: "parse", + value: function parse(dateString) { + return parseAnyDigitsSigned(dateString); + } + }, { + key: "set", + value: function set(_date, _flags, value) { + return [new Date(value * 1000), { + timestampIsSet: true + }]; + } + }]); + return TimestampSecondsParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js b/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js new file mode 100644 index 0000000..bb1b813 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js @@ -0,0 +1,73 @@ +import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; +import _createClass from "@babel/runtime/helpers/esm/createClass"; +import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; +import _inherits from "@babel/runtime/helpers/esm/inherits"; +import _createSuper from "@babel/runtime/helpers/esm/createSuper"; +import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; +import { Parser } from "../Parser.js"; +import { mapValue, normalizeTwoDigitYear, parseNDigits } from "../utils.js"; +// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns +// | Year | y | yy | yyy | yyyy | yyyyy | +// |----------|-------|----|-------|-------|-------| +// | AD 1 | 1 | 01 | 001 | 0001 | 00001 | +// | AD 12 | 12 | 12 | 012 | 0012 | 00012 | +// | AD 123 | 123 | 23 | 123 | 0123 | 00123 | +// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 | +// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 | +export var YearParser = /*#__PURE__*/function (_Parser) { + _inherits(YearParser, _Parser); + var _super = _createSuper(YearParser); + function YearParser() { + var _this; + _classCallCheck(this, YearParser); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "priority", 130); + _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']); + return _this; + } + _createClass(YearParser, [{ + key: "parse", + value: function parse(dateString, token, match) { + var valueCallback = function valueCallback(year) { + return { + year: year, + isTwoDigitYear: token === 'yy' + }; + }; + switch (token) { + case 'y': + return mapValue(parseNDigits(4, dateString), valueCallback); + case 'yo': + return mapValue(match.ordinalNumber(dateString, { + unit: 'year' + }), valueCallback); + default: + return mapValue(parseNDigits(token.length, dateString), valueCallback); + } + } + }, { + key: "validate", + value: function validate(_date, value) { + return value.isTwoDigitYear || value.year > 0; + } + }, { + key: "set", + value: function set(date, flags, value) { + var currentYear = date.getUTCFullYear(); + if (value.isTwoDigitYear) { + var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear); + date.setUTCFullYear(normalizedTwoDigitYear, 0, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year; + date.setUTCFullYear(year, 0, 1); + date.setUTCHours(0, 0, 0, 0); + return date; + } + }]); + return YearParser; +}(Parser);
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/parsers/index.js b/node_modules/date-fns/esm/parse/_lib/parsers/index.js new file mode 100644 index 0000000..647341c --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/parsers/index.js @@ -0,0 +1,107 @@ +import { EraParser } from "./EraParser.js"; +import { YearParser } from "./YearParser.js"; +import { LocalWeekYearParser } from "./LocalWeekYearParser.js"; +import { ISOWeekYearParser } from "./ISOWeekYearParser.js"; +import { ExtendedYearParser } from "./ExtendedYearParser.js"; +import { QuarterParser } from "./QuarterParser.js"; +import { StandAloneQuarterParser } from "./StandAloneQuarterParser.js"; +import { MonthParser } from "./MonthParser.js"; +import { StandAloneMonthParser } from "./StandAloneMonthParser.js"; +import { LocalWeekParser } from "./LocalWeekParser.js"; +import { ISOWeekParser } from "./ISOWeekParser.js"; +import { DateParser } from "./DateParser.js"; +import { DayOfYearParser } from "./DayOfYearParser.js"; +import { DayParser } from "./DayParser.js"; +import { LocalDayParser } from "./LocalDayParser.js"; +import { StandAloneLocalDayParser } from "./StandAloneLocalDayParser.js"; +import { ISODayParser } from "./ISODayParser.js"; +import { AMPMParser } from "./AMPMParser.js"; +import { AMPMMidnightParser } from "./AMPMMidnightParser.js"; +import { DayPeriodParser } from "./DayPeriodParser.js"; +import { Hour1to12Parser } from "./Hour1to12Parser.js"; +import { Hour0to23Parser } from "./Hour0to23Parser.js"; +import { Hour0To11Parser } from "./Hour0To11Parser.js"; +import { Hour1To24Parser } from "./Hour1To24Parser.js"; +import { MinuteParser } from "./MinuteParser.js"; +import { SecondParser } from "./SecondParser.js"; +import { FractionOfSecondParser } from "./FractionOfSecondParser.js"; +import { ISOTimezoneWithZParser } from "./ISOTimezoneWithZParser.js"; +import { ISOTimezoneParser } from "./ISOTimezoneParser.js"; +import { TimestampSecondsParser } from "./TimestampSecondsParser.js"; +import { TimestampMillisecondsParser } from "./TimestampMillisecondsParser.js"; +/* + * | | Unit | | Unit | + * |-----|--------------------------------|-----|--------------------------------| + * | a | AM, PM | A* | Milliseconds in day | + * | b | AM, PM, noon, midnight | B | Flexible day period | + * | c | Stand-alone local day of week | C* | Localized hour w/ day period | + * | d | Day of month | D | Day of year | + * | e | Local day of week | E | Day of week | + * | f | | F* | Day of week in month | + * | g* | Modified Julian day | G | Era | + * | h | Hour [1-12] | H | Hour [0-23] | + * | i! | ISO day of week | I! | ISO week of year | + * | j* | Localized hour w/ day period | J* | Localized hour w/o day period | + * | k | Hour [1-24] | K | Hour [0-11] | + * | l* | (deprecated) | L | Stand-alone month | + * | m | Minute | M | Month | + * | n | | N | | + * | o! | Ordinal number modifier | O* | Timezone (GMT) | + * | p | | P | | + * | q | Stand-alone quarter | Q | Quarter | + * | r* | Related Gregorian year | R! | ISO week-numbering year | + * | s | Second | S | Fraction of second | + * | t! | Seconds timestamp | T! | Milliseconds timestamp | + * | u | Extended year | U* | Cyclic year | + * | v* | Timezone (generic non-locat.) | V* | Timezone (location) | + * | w | Local week of year | W* | Week of month | + * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) | + * | y | Year (abs) | Y | Local week-numbering year | + * | z* | Timezone (specific non-locat.) | Z* | Timezone (aliases) | + * + * Letters marked by * are not implemented but reserved by Unicode standard. + * + * Letters marked by ! are non-standard, but implemented by date-fns: + * - `o` modifies the previous token to turn it into an ordinal (see `parse` docs) + * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days, + * i.e. 7 for Sunday, 1 for Monday, etc. + * - `I` is ISO week of year, as opposed to `w` which is local week of year. + * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year. + * `R` is supposed to be used in conjunction with `I` and `i` + * for universal ISO week-numbering date, whereas + * `Y` is supposed to be used in conjunction with `w` and `e` + * for week-numbering date specific to the locale. + */ +export var parsers = { + G: new EraParser(), + y: new YearParser(), + Y: new LocalWeekYearParser(), + R: new ISOWeekYearParser(), + u: new ExtendedYearParser(), + Q: new QuarterParser(), + q: new StandAloneQuarterParser(), + M: new MonthParser(), + L: new StandAloneMonthParser(), + w: new LocalWeekParser(), + I: new ISOWeekParser(), + d: new DateParser(), + D: new DayOfYearParser(), + E: new DayParser(), + e: new LocalDayParser(), + c: new StandAloneLocalDayParser(), + i: new ISODayParser(), + a: new AMPMParser(), + b: new AMPMMidnightParser(), + B: new DayPeriodParser(), + h: new Hour1to12Parser(), + H: new Hour0to23Parser(), + K: new Hour0To11Parser(), + k: new Hour1To24Parser(), + m: new MinuteParser(), + s: new SecondParser(), + S: new FractionOfSecondParser(), + X: new ISOTimezoneWithZParser(), + x: new ISOTimezoneParser(), + t: new TimestampSecondsParser(), + T: new TimestampMillisecondsParser() +};
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/types.js b/node_modules/date-fns/esm/parse/_lib/types.js new file mode 100644 index 0000000..8cec2e9 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/types.js @@ -0,0 +1 @@ +export {};
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/_lib/utils.js b/node_modules/date-fns/esm/parse/_lib/utils.js new file mode 100644 index 0000000..1a855a3 --- /dev/null +++ b/node_modules/date-fns/esm/parse/_lib/utils.js @@ -0,0 +1,112 @@ +import { millisecondsInHour, millisecondsInMinute, millisecondsInSecond } from "../../constants/index.js"; +import { numericPatterns } from "./constants.js"; +export function mapValue(parseFnResult, mapFn) { + if (!parseFnResult) { + return parseFnResult; + } + return { + value: mapFn(parseFnResult.value), + rest: parseFnResult.rest + }; +} +export function parseNumericPattern(pattern, dateString) { + var matchResult = dateString.match(pattern); + if (!matchResult) { + return null; + } + return { + value: parseInt(matchResult[0], 10), + rest: dateString.slice(matchResult[0].length) + }; +} +export function parseTimezonePattern(pattern, dateString) { + var matchResult = dateString.match(pattern); + if (!matchResult) { + return null; + } + + // Input is 'Z' + if (matchResult[0] === 'Z') { + return { + value: 0, + rest: dateString.slice(1) + }; + } + var sign = matchResult[1] === '+' ? 1 : -1; + var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0; + var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0; + var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0; + return { + value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond), + rest: dateString.slice(matchResult[0].length) + }; +} +export function parseAnyDigitsSigned(dateString) { + return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString); +} +export function parseNDigits(n, dateString) { + switch (n) { + case 1: + return parseNumericPattern(numericPatterns.singleDigit, dateString); + case 2: + return parseNumericPattern(numericPatterns.twoDigits, dateString); + case 3: + return parseNumericPattern(numericPatterns.threeDigits, dateString); + case 4: + return parseNumericPattern(numericPatterns.fourDigits, dateString); + default: + return parseNumericPattern(new RegExp('^\\d{1,' + n + '}'), dateString); + } +} +export function parseNDigitsSigned(n, dateString) { + switch (n) { + case 1: + return parseNumericPattern(numericPatterns.singleDigitSigned, dateString); + case 2: + return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString); + case 3: + return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString); + case 4: + return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString); + default: + return parseNumericPattern(new RegExp('^-?\\d{1,' + n + '}'), dateString); + } +} +export function dayPeriodEnumToHours(dayPeriod) { + switch (dayPeriod) { + case 'morning': + return 4; + case 'evening': + return 17; + case 'pm': + case 'noon': + case 'afternoon': + return 12; + case 'am': + case 'midnight': + case 'night': + default: + return 0; + } +} +export function normalizeTwoDigitYear(twoDigitYear, currentYear) { + var isCommonEra = currentYear > 0; + // Absolute number of the current year: + // 1 -> 1 AC + // 0 -> 1 BC + // -1 -> 2 BC + var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear; + var result; + if (absCurrentYear <= 50) { + result = twoDigitYear || 100; + } else { + var rangeEnd = absCurrentYear + 50; + var rangeEndCentury = Math.floor(rangeEnd / 100) * 100; + var isPreviousCentury = twoDigitYear >= rangeEnd % 100; + result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0); + } + return isCommonEra ? result : 1 - result; +} +export function isLeapYearIndex(year) { + return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0; +}
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/index.d.ts b/node_modules/date-fns/esm/parse/index.d.ts new file mode 100644 index 0000000..2c5eb60 --- /dev/null +++ b/node_modules/date-fns/esm/parse/index.d.ts @@ -0,0 +1,4 @@ +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +import { parse } from 'date-fns' +export default parse diff --git a/node_modules/date-fns/esm/parse/index.js b/node_modules/date-fns/esm/parse/index.js new file mode 100644 index 0000000..f6cdb0f --- /dev/null +++ b/node_modules/date-fns/esm/parse/index.js @@ -0,0 +1,505 @@ +import _typeof from "@babel/runtime/helpers/esm/typeof"; +import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper"; +import defaultLocale from "../_lib/defaultLocale/index.js"; +import subMilliseconds from "../subMilliseconds/index.js"; +import toDate from "../toDate/index.js"; +import assign from "../_lib/assign/index.js"; +import longFormatters from "../_lib/format/longFormatters/index.js"; +import getTimezoneOffsetInMilliseconds from "../_lib/getTimezoneOffsetInMilliseconds/index.js"; +import { isProtectedDayOfYearToken, isProtectedWeekYearToken, throwProtectedError } from "../_lib/protectedTokens/index.js"; +import toInteger from "../_lib/toInteger/index.js"; +import requiredArgs from "../_lib/requiredArgs/index.js"; +import { DateToSystemTimezoneSetter } from "./_lib/Setter.js"; +import { parsers } from "./_lib/parsers/index.js"; +import { getDefaultOptions } from "../_lib/defaultOptions/index.js"; // This RegExp consists of three parts separated by `|`: +// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token +// (one of the certain letters followed by `o`) +// - (\w)\1* matches any sequences of the same letter +// - '' matches two quote characters in a row +// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('), +// except a single quote symbol, which ends the sequence. +// Two quote characters do not end the sequence. +// If there is no matching single quote +// then the sequence will continue until the end of the string. +// - . matches any single character unmatched by previous parts of the RegExps +var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; + +// This RegExp catches symbols escaped by quotes, and also +// sequences of symbols P, p, and the combinations like `PPPPPPPppppp` +var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; +var escapedStringRegExp = /^'([^]*?)'?$/; +var doubleQuoteRegExp = /''/g; +var notWhitespaceRegExp = /\S/; +var unescapedLatinCharacterRegExp = /[a-zA-Z]/; + +/** + * @name parse + * @category Common Helpers + * @summary Parse the date. + * + * @description + * Return the date parsed from string using the given format string. + * + * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries. + * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * + * The characters in the format string wrapped between two single quotes characters (') are escaped. + * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. + * + * Format of the format string is based on Unicode Technical Standard #35: + * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table + * with a few additions (see note 5 below the table). + * + * Not all tokens are compatible. Combinations that don't make sense or could lead to bugs are prohibited + * and will throw `RangeError`. For example usage of 24-hour format token with AM/PM token will throw an exception: + * + * ```javascript + * parse('23 AM', 'HH a', new Date()) + * //=> RangeError: The format string mustn't contain `HH` and `a` at the same time + * ``` + * + * See the compatibility table: https://docs.google.com/spreadsheets/d/e/2PACX-1vQOPU3xUhplll6dyoMmVUXHKl_8CRDs6_ueLmex3SoqwhuolkuN3O05l4rqx5h1dKX8eb46Ul-CCSrq/pubhtml?gid=0&single=true + * + * Accepted format string patterns: + * | Unit |Prior| Pattern | Result examples | Notes | + * |---------------------------------|-----|---------|-----------------------------------|-------| + * | Era | 140 | G..GGG | AD, BC | | + * | | | GGGG | Anno Domini, Before Christ | 2 | + * | | | GGGGG | A, B | | + * | Calendar year | 130 | y | 44, 1, 1900, 2017, 9999 | 4 | + * | | | yo | 44th, 1st, 1900th, 9999999th | 4,5 | + * | | | yy | 44, 01, 00, 17 | 4 | + * | | | yyy | 044, 001, 123, 999 | 4 | + * | | | yyyy | 0044, 0001, 1900, 2017 | 4 | + * | | | yyyyy | ... | 2,4 | + * | Local week-numbering year | 130 | Y | 44, 1, 1900, 2017, 9000 | 4 | + * | | | Yo | 44th, 1st, 1900th, 9999999th | 4,5 | + * | | | YY | 44, 01, 00, 17 | 4,6 | + * | | | YYY | 044, 001, 123, 999 | 4 | + * | | | YYYY | 0044, 0001, 1900, 2017 | 4,6 | + * | | | YYYYY | ... | 2,4 | + * | ISO week-numbering year | 130 | R | -43, 1, 1900, 2017, 9999, -9999 | 4,5 | + * | | | RR | -43, 01, 00, 17 | 4,5 | + * | | | RRR | -043, 001, 123, 999, -999 | 4,5 | + * | | | RRRR | -0043, 0001, 2017, 9999, -9999 | 4,5 | + * | | | RRRRR | ... | 2,4,5 | + * | Extended year | 130 | u | -43, 1, 1900, 2017, 9999, -999 | 4 | + * | | | uu | -43, 01, 99, -99 | 4 | + * | | | uuu | -043, 001, 123, 999, -999 | 4 | + * | | | uuuu | -0043, 0001, 2017, 9999, -9999 | 4 | + * | | | uuuuu | ... | 2,4 | + * | Quarter (formatting) | 120 | Q | 1, 2, 3, 4 | | + * | | | Qo | 1st, 2nd, 3rd, 4th | 5 | + * | | | QQ | 01, 02, 03, 04 | | + * | | | QQQ | Q1, Q2, Q3, Q4 | | + * | | | QQQQ | 1st quarter, 2nd quarter, ... | 2 | + * | | | QQQQQ | 1, 2, 3, 4 | 4 | + * | Quarter (stand-alone) | 120 | q | 1, 2, 3, 4 | | + * | | | qo | 1st, 2nd, 3rd, 4th | 5 | + * | | | qq | 01, 02, 03, 04 | | + * | | | qqq | Q1, Q2, Q3, Q4 | | + * | | | qqqq | 1st quarter, 2nd quarter, ... | 2 | + * | | | qqqqq | 1, 2, 3, 4 | 3 | + * | Month (formatting) | 110 | M | 1, 2, ..., 12 | | + * | | | Mo | 1st, 2nd, ..., 12th | 5 | + * | | | MM | 01, 02, ..., 12 | | + * | | | MMM | Jan, Feb, ..., Dec | | + * | | | MMMM | January, February, ..., December | 2 | + * | | | MMMMM | J, F, ..., D | | + * | Month (stand-alone) | 110 | L | 1, 2, ..., 12 | | + * | | | Lo | 1st, 2nd, ..., 12th | 5 | + * | | | LL | 01, 02, ..., 12 | | + * | | | LLL | Jan, Feb, ..., Dec | | + * | | | LLLL | January, February, ..., December | 2 | + * | | | LLLLL | J, F, ..., D | | + * | Local week of year | 100 | w | 1, 2, ..., 53 | | + * | | | wo | 1st, 2nd, ..., 53th | 5 | + * | | | ww | 01, 02, ..., 53 | | + * | ISO week of year | 100 | I | 1, 2, ..., 53 | 5 | + * | | | Io | 1st, 2nd, ..., 53th | 5 | + * | | | II | 01, 02, ..., 53 | 5 | + * | Day of month | 90 | d | 1, 2, ..., 31 | | + * | | | do | 1st, 2nd, ..., 31st | 5 | + * | | | dd | 01, 02, ..., 31 | | + * | Day of year | 90 | D | 1, 2, ..., 365, 366 | 7 | + * | | | Do | 1st, 2nd, ..., 365th, 366th | 5 | + * | | | DD | 01, 02, ..., 365, 366 | 7 | + * | | | DDD | 001, 002, ..., 365, 366 | | + * | | | DDDD | ... | 2 | + * | Day of week (formatting) | 90 | E..EEE | Mon, Tue, Wed, ..., Sun | | + * | | | EEEE | Monday, Tuesday, ..., Sunday | 2 | + * | | | EEEEE | M, T, W, T, F, S, S | | + * | | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | | + * | ISO day of week (formatting) | 90 | i | 1, 2, 3, ..., 7 | 5 | + * | | | io | 1st, 2nd, ..., 7th | 5 | + * | | | ii | 01, 02, ..., 07 | 5 | + * | | | iii | Mon, Tue, Wed, ..., Sun | 5 | + * | | | iiii | Monday, Tuesday, ..., Sunday | 2,5 | + * | | | iiiii | M, T, W, T, F, S, S | 5 | + * | | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 5 | + * | Local day of week (formatting) | 90 | e | 2, 3, 4, ..., 1 | | + * | | | eo | 2nd, 3rd, ..., 1st | 5 | + * | | | ee | 02, 03, ..., 01 | | + * | | | eee | Mon, Tue, Wed, ..., Sun | | + * | | | eeee | Monday, Tuesday, ..., Sunday | 2 | + * | | | eeeee | M, T, W, T, F, S, S | | + * | | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | | + * | Local day of week (stand-alone) | 90 | c | 2, 3, 4, ..., 1 | | + * | | | co | 2nd, 3rd, ..., 1st | 5 | + * | | | cc | 02, 03, ..., 01 | | + * | | | ccc | Mon, Tue, Wed, ..., Sun | | + * | | | cccc | Monday, Tuesday, ..., Sunday | 2 | + * | | | ccccc | M, T, W, T, F, S, S | | + * | | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | | + * | AM, PM | 80 | a..aaa | AM, PM | | + * | | | aaaa | a.m., p.m. | 2 | + * | | | aaaaa | a, p | | + * | AM, PM, noon, midnight | 80 | b..bbb | AM, PM, noon, midnight | | + * | | | bbbb | a.m., p.m., noon, midnight | 2 | + * | | | bbbbb | a, p, n, mi | | + * | Flexible day period | 80 | B..BBB | at night, in the morning, ... | | + * | | | BBBB | at night, in the morning, ... | 2 | + * | | | BBBBB | at night, in the morning, ... | | + * | Hour [1-12] | 70 | h | 1, 2, ..., 11, 12 | | + * | | | ho | 1st, 2nd, ..., 11th, 12th | 5 | + * | | | hh | 01, 02, ..., 11, 12 | | + * | Hour [0-23] | 70 | H | 0, 1, 2, ..., 23 | | + * | | | Ho | 0th, 1st, 2nd, ..., 23rd | 5 | + * | | | HH | 00, 01, 02, ..., 23 | | + * | Hour [0-11] | 70 | K | 1, 2, ..., 11, 0 | | + * | | | Ko | 1st, 2nd, ..., 11th, 0th | 5 | + * | | | KK | 01, 02, ..., 11, 00 | | + * | Hour [1-24] | 70 | k | 24, 1, 2, ..., 23 | | + * | | | ko | 24th, 1st, 2nd, ..., 23rd | 5 | + * | | | kk | 24, 01, 02, ..., 23 | | + * | Minute | 60 | m | 0, 1, ..., 59 | | + * | | | mo | 0th, 1st, ..., 59th | 5 | + * | | | mm | 00, 01, ..., 59 | | + * | Second | 50 | s | 0, 1, ..., 59 | | + * | | | so | 0th, 1st, ..., 59th | 5 | + * | | | ss | 00, 01, ..., 59 | | + * | Seconds timestamp | 40 | t | 512969520 | | + * | | | tt | ... | 2 | + * | Fraction of second | 30 | S | 0, 1, ..., 9 | | + * | | | SS | 00, 01, ..., 99 | | + * | | | SSS | 000, 001, ..., 999 | | + * | | | SSSS | ... | 2 | + * | Milliseconds timestamp | 20 | T | 512969520900 | | + * | | | TT | ... | 2 | + * | Timezone (ISO-8601 w/ Z) | 10 | X | -08, +0530, Z | | + * | | | XX | -0800, +0530, Z | | + * | | | XXX | -08:00, +05:30, Z | | + * | | | XXXX | -0800, +0530, Z, +123456 | 2 | + * | | | XXXXX | -08:00, +05:30, Z, +12:34:56 | | + * | Timezone (ISO-8601 w/o Z) | 10 | x | -08, +0530, +00 | | + * | | | xx | -0800, +0530, +0000 | | + * | | | xxx | -08:00, +05:30, +00:00 | 2 | + * | | | xxxx | -0800, +0530, +0000, +123456 | | + * | | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | | + * | Long localized date | NA | P | 05/29/1453 | 5,8 | + * | | | PP | May 29, 1453 | | + * | | | PPP | May 29th, 1453 | | + * | | | PPPP | Sunday, May 29th, 1453 | 2,5,8 | + * | Long localized time | NA | p | 12:00 AM | 5,8 | + * | | | pp | 12:00:00 AM | | + * | Combination of date and time | NA | Pp | 05/29/1453, 12:00 AM | | + * | | | PPpp | May 29, 1453, 12:00:00 AM | | + * | | | PPPpp | May 29th, 1453 at ... | | + * | | | PPPPpp | Sunday, May 29th, 1453 at ... | 2,5,8 | + * Notes: + * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale + * are the same as "stand-alone" units, but are different in some languages. + * "Formatting" units are declined according to the rules of the language + * in the context of a date. "Stand-alone" units are always nominative singular. + * In `format` function, they will produce different result: + * + * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'` + * + * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'` + * + * `parse` will try to match both formatting and stand-alone units interchangably. + * + * 2. Any sequence of the identical letters is a pattern, unless it is escaped by + * the single quote characters (see below). + * If the sequence is longer than listed in table: + * - for numerical units (`yyyyyyyy`) `parse` will try to match a number + * as wide as the sequence + * - for text units (`MMMMMMMM`) `parse` will try to match the widest variation of the unit. + * These variations are marked with "2" in the last column of the table. + * + * 3. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales. + * These tokens represent the shortest form of the quarter. + * + * 4. The main difference between `y` and `u` patterns are B.C. years: + * + * | Year | `y` | `u` | + * |------|-----|-----| + * | AC 1 | 1 | 1 | + * | BC 1 | 1 | 0 | + * | BC 2 | 2 | -1 | + * + * Also `yy` will try to guess the century of two digit year by proximity with `referenceDate`: + * + * `parse('50', 'yy', new Date(2018, 0, 1)) //=> Sat Jan 01 2050 00:00:00` + * + * `parse('75', 'yy', new Date(2018, 0, 1)) //=> Wed Jan 01 1975 00:00:00` + * + * while `uu` will just assign the year as is: + * + * `parse('50', 'uu', new Date(2018, 0, 1)) //=> Sat Jan 01 0050 00:00:00` + * + * `parse('75', 'uu', new Date(2018, 0, 1)) //=> Tue Jan 01 0075 00:00:00` + * + * The same difference is true for local and ISO week-numbering years (`Y` and `R`), + * except local week-numbering years are dependent on `options.weekStartsOn` + * and `options.firstWeekContainsDate` (compare [setISOWeekYear]{@link https://date-fns.org/docs/setISOWeekYear} + * and [setWeekYear]{@link https://date-fns.org/docs/setWeekYear}). + * + * 5. These patterns are not in the Unicode Technical Standard #35: + * - `i`: ISO day of week + * - `I`: ISO week of year + * - `R`: ISO week-numbering year + * - `o`: ordinal number modifier + * - `P`: long localized date + * - `p`: long localized time + * + * 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. + * 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 + * on the given locale. + * + * using `en-US` locale: `P` => `MM/dd/yyyy` + * using `en-US` locale: `p` => `hh:mm a` + * using `pt-BR` locale: `P` => `dd/MM/yyyy` + * using `pt-BR` locale: `p` => `HH:mm` + * + * Values will be assigned to the date in the descending order of its unit's priority. + * Units of an equal priority overwrite each other in the order of appearance. + * + * If no values of higher priority are parsed (e.g. when parsing string 'January 1st' without a year), + * the values will be taken from 3rd argument `referenceDate` which works as a context of parsing. + * + * `referenceDate` must be passed for correct work of the function. + * If you're not sure which `referenceDate` to supply, create a new instance of Date: + * `parse('02/11/2014', 'MM/dd/yyyy', new Date())` + * In this case parsing will be done in the context of the current date. + * If `referenceDate` is `Invalid Date` or a value not convertible to valid `Date`, + * then `Invalid Date` will be returned. + * + * The result may vary by locale. + * + * If `formatString` matches with `dateString` but does not provides tokens, `referenceDate` will be returned. + * + * If parsing failed, `Invalid Date` will be returned. + * Invalid Date is a Date, whose time value is NaN. + * Time value of Date: http://es5.github.io/#x15.9.1.1 + * + * @param {String} dateString - the string to parse + * @param {String} formatString - the string of tokens + * @param {Date|Number} referenceDate - defines values missing from the parsed dateString + * @param {Object} [options] - an object with options. + * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} + * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday) + * @param {1|2|3|4|5|6|7} [options.firstWeekContainsDate=1] - the day of January, which is always in the first week of the year + * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`; + * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`; + * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @returns {Date} the parsed date + * @throws {TypeError} 3 arguments required + * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6 + * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7 + * @throws {RangeError} `options.locale` must contain `match` property + * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md + * @throws {RangeError} format string contains an unescaped latin alphabet character + * + * @example + * // Parse 11 February 2014 from middle-endian format: + * var result = parse('02/11/2014', 'MM/dd/yyyy', new Date()) + * //=> Tue Feb 11 2014 00:00:00 + * + * @example + * // Parse 28th of February in Esperanto locale in the context of 2010 year: + * import eo from 'date-fns/locale/eo' + * var result = parse('28-a de februaro', "do 'de' MMMM", new Date(2010, 0, 1), { + * locale: eo + * }) + * //=> Sun Feb 28 2010 00:00:00 + */ +export default function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, options) { + var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4; + requiredArgs(3, arguments); + var dateString = String(dirtyDateString); + var formatString = String(dirtyFormatString); + var defaultOptions = getDefaultOptions(); + var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale; + if (!locale.match) { + throw new RangeError('locale must contain match property'); + } + var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1); + + // Test if weekStartsOn is between 1 and 7 _and_ is not NaN + if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) { + throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively'); + } + var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0); + + // 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'); + } + if (formatString === '') { + if (dateString === '') { + return toDate(dirtyReferenceDate); + } else { + return new Date(NaN); + } + } + var subFnOptions = { + firstWeekContainsDate: firstWeekContainsDate, + weekStartsOn: weekStartsOn, + locale: locale + }; + + // If timezone isn't specified, it will be set to the system timezone + var setters = [new DateToSystemTimezoneSetter()]; + var tokens = formatString.match(longFormattingTokensRegExp).map(function (substring) { + var firstCharacter = substring[0]; + if (firstCharacter in longFormatters) { + var longFormatter = longFormatters[firstCharacter]; + return longFormatter(substring, locale.formatLong); + } + return substring; + }).join('').match(formattingTokensRegExp); + var usedTokens = []; + var _iterator = _createForOfIteratorHelper(tokens), + _step; + try { + var _loop = function _loop() { + var token = _step.value; + if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token)) { + throwProtectedError(token, formatString, dirtyDateString); + } + if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) { + throwProtectedError(token, formatString, dirtyDateString); + } + var firstCharacter = token[0]; + var parser = parsers[firstCharacter]; + if (parser) { + var incompatibleTokens = parser.incompatibleTokens; + if (Array.isArray(incompatibleTokens)) { + var incompatibleToken = usedTokens.find(function (usedToken) { + return incompatibleTokens.includes(usedToken.token) || usedToken.token === firstCharacter; + }); + if (incompatibleToken) { + throw new RangeError("The format string mustn't contain `".concat(incompatibleToken.fullToken, "` and `").concat(token, "` at the same time")); + } + } else if (parser.incompatibleTokens === '*' && usedTokens.length > 0) { + throw new RangeError("The format string mustn't contain `".concat(token, "` and any other token at the same time")); + } + usedTokens.push({ + token: firstCharacter, + fullToken: token + }); + var parseResult = parser.run(dateString, token, locale.match, subFnOptions); + if (!parseResult) { + return { + v: new Date(NaN) + }; + } + setters.push(parseResult.setter); + dateString = parseResult.rest; + } else { + if (firstCharacter.match(unescapedLatinCharacterRegExp)) { + throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`'); + } + + // Replace two single quote characters with one single quote character + if (token === "''") { + token = "'"; + } else if (firstCharacter === "'") { + token = cleanEscapedString(token); + } + + // Cut token from string, or, if string doesn't match the token, return Invalid Date + if (dateString.indexOf(token) === 0) { + dateString = dateString.slice(token.length); + } else { + return { + v: new Date(NaN) + }; + } + } + }; + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _ret = _loop(); + if (_typeof(_ret) === "object") return _ret.v; + } + + // Check if the remaining input contains something other than whitespace + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + if (dateString.length > 0 && notWhitespaceRegExp.test(dateString)) { + return new Date(NaN); + } + var uniquePrioritySetters = setters.map(function (setter) { + return setter.priority; + }).sort(function (a, b) { + return b - a; + }).filter(function (priority, index, array) { + return array.indexOf(priority) === index; + }).map(function (priority) { + return setters.filter(function (setter) { + return setter.priority === priority; + }).sort(function (a, b) { + return b.subPriority - a.subPriority; + }); + }).map(function (setterArray) { + return setterArray[0]; + }); + var date = toDate(dirtyReferenceDate); + if (isNaN(date.getTime())) { + return new Date(NaN); + } + + // Convert the date in system timezone to the same date in UTC+00:00 timezone. + var utcDate = subMilliseconds(date, getTimezoneOffsetInMilliseconds(date)); + var flags = {}; + var _iterator2 = _createForOfIteratorHelper(uniquePrioritySetters), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var setter = _step2.value; + if (!setter.validate(utcDate, subFnOptions)) { + return new Date(NaN); + } + var result = setter.set(utcDate, flags, subFnOptions); + // Result is tuple (date, flags) + if (Array.isArray(result)) { + utcDate = result[0]; + assign(flags, result[1]); + // Result is date + } else { + utcDate = result; + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + return utcDate; +} +function cleanEscapedString(input) { + return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'"); +}
\ No newline at end of file diff --git a/node_modules/date-fns/esm/parse/index.js.flow b/node_modules/date-fns/esm/parse/index.js.flow new file mode 100644 index 0000000..f8e1cfe --- /dev/null +++ b/node_modules/date-fns/esm/parse/index.js.flow @@ -0,0 +1,63 @@ +// @flow +// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it. + +export type Interval = { + start: Date | number, + end: Date | number, +} + +export type Locale = { + code?: string, + formatDistance?: (...args: Array<any>) => any, + formatRelative?: (...args: Array<any>) => any, + localize?: { + ordinalNumber: (...args: Array<any>) => any, + era: (...args: Array<any>) => any, + quarter: (...args: Array<any>) => any, + month: (...args: Array<any>) => any, + day: (...args: Array<any>) => any, + dayPeriod: (...args: Array<any>) => any, + }, + formatLong?: { + date: (...args: Array<any>) => any, + time: (...args: Array<any>) => any, + dateTime: (...args: Array<any>) => any, + }, + match?: { + ordinalNumber: (...args: Array<any>) => any, + era: (...args: Array<any>) => any, + quarter: (...args: Array<any>) => any, + month: (...args: Array<any>) => any, + day: (...args: Array<any>) => any, + dayPeriod: (...args: Array<any>) => any, + }, + options?: { + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7, + }, +} + +export type Duration = { + years?: number, + months?: number, + weeks?: number, + days?: number, + hours?: number, + minutes?: number, + seconds?: number, +} + +export type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6 + +declare module.exports: ( + dateString: string, + formatString: string, + referenceDate: Date | number, + options?: { + locale?: Locale, + weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6, + firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7, + useAdditionalWeekYearTokens?: boolean, + useAdditionalDayOfYearTokens?: boolean, + } +) => Date diff --git a/node_modules/date-fns/esm/parse/package.json b/node_modules/date-fns/esm/parse/package.json new file mode 100644 index 0000000..b109f05 --- /dev/null +++ b/node_modules/date-fns/esm/parse/package.json @@ -0,0 +1,4 @@ +{ + "sideEffects": false, + "typings": "../../typings.d.ts" +}
\ No newline at end of file |
