This commit is contained in:
root
2025-11-25 09:56:15 +03:00
commit 68c8f0e80d
23717 changed files with 3200521 additions and 0 deletions

View File

@ -0,0 +1,72 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AMPMMidnightParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var AMPMMidnightParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(AMPMMidnightParser, _Parser);
var _super = (0, _createSuper2.default)(AMPMMidnightParser);
function AMPMMidnightParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 80);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['a', 'B', 'H', 'k', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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((0, _utils.dayPeriodEnumToHours)(value), 0, 0, 0);
return date;
}
}]);
return AMPMMidnightParser;
}(_Parser2.Parser);
exports.AMPMMidnightParser = AMPMMidnightParser;

View File

@ -0,0 +1,72 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AMPMParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var AMPMParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(AMPMParser, _Parser);
var _super = (0, _createSuper2.default)(AMPMParser);
function AMPMParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 80);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['b', 'B', 'H', 'k', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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((0, _utils.dayPeriodEnumToHours)(value), 0, 0, 0);
return date;
}
}]);
return AMPMParser;
}(_Parser2.Parser);
exports.AMPMParser = AMPMParser;

View File

@ -0,0 +1,72 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DateParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _utils = require("../utils.js");
var _Parser2 = require("../Parser.js");
var _constants = require("../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
var DateParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(DateParser, _Parser);
var _super = (0, _createSuper2.default)(DateParser);
function DateParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subPriority", 1);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(DateParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'd':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.date, dateString);
case 'do':
return match.ordinalNumber(dateString, {
unit: 'date'
});
default:
return (0, _utils.parseNDigits)(token.length, dateString);
}
}
}, {
key: "validate",
value: function validate(date, value) {
var year = date.getUTCFullYear();
var isLeapYear = (0, _utils.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;
}(_Parser2.Parser);
exports.DateParser = DateParser;

View File

@ -0,0 +1,68 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DayOfYearParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var DayOfYearParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(DayOfYearParser, _Parser);
var _super = (0, _createSuper2.default)(DayOfYearParser);
function DayOfYearParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subpriority", 1);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'L', 'w', 'I', 'd', 'E', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(DayOfYearParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'D':
case 'DD':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.dayOfYear, dateString);
case 'Do':
return match.ordinalNumber(dateString, {
unit: 'date'
});
default:
return (0, _utils.parseNDigits)(token.length, dateString);
}
}
}, {
key: "validate",
value: function validate(date, value) {
var year = date.getUTCFullYear();
var isLeapYear = (0, _utils.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;
}(_Parser2.Parser);
exports.DayOfYearParser = DayOfYearParser;

View File

@ -0,0 +1,97 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DayParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCDay/index.js"));
// Day of week
var DayParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(DayParser, _Parser);
var _super = (0, _createSuper2.default)(DayParser);
function DayParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['D', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 = (0, _index.default)(date, value, options);
date.setUTCHours(0, 0, 0, 0);
return date;
}
}]);
return DayParser;
}(_Parser2.Parser);
exports.DayParser = DayParser;

View File

@ -0,0 +1,73 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DayPeriodParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
// in the morning, in the afternoon, in the evening, at night
var DayPeriodParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(DayPeriodParser, _Parser);
var _super = (0, _createSuper2.default)(DayPeriodParser);
function DayPeriodParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 80);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['a', 'b', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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((0, _utils.dayPeriodEnumToHours)(value), 0, 0, 0);
return date;
}
}]);
return DayPeriodParser;
}(_Parser2.Parser);
exports.DayPeriodParser = DayPeriodParser;

View File

@ -0,0 +1,70 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EraParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var EraParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(EraParser, _Parser);
var _super = (0, _createSuper2.default)(EraParser);
function EraParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 140);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['R', 'u', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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;
}(_Parser2.Parser);
exports.EraParser = EraParser;

View File

@ -0,0 +1,48 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ExtendedYearParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var ExtendedYearParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ExtendedYearParser, _Parser);
var _super = (0, _createSuper2.default)(ExtendedYearParser);
function ExtendedYearParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 130);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['G', 'y', 'Y', 'R', 'w', 'I', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(ExtendedYearParser, [{
key: "parse",
value: function parse(dateString, token) {
if (token === 'u') {
return (0, _utils.parseNDigitsSigned)(4, dateString);
}
return (0, _utils.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;
}(_Parser2.Parser);
exports.ExtendedYearParser = ExtendedYearParser;

View File

@ -0,0 +1,47 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FractionOfSecondParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var FractionOfSecondParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(FractionOfSecondParser, _Parser);
var _super = (0, _createSuper2.default)(FractionOfSecondParser);
function FractionOfSecondParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 30);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['t', 'T']);
return _this;
}
(0, _createClass2.default)(FractionOfSecondParser, [{
key: "parse",
value: function parse(dateString, token) {
var valueCallback = function valueCallback(value) {
return Math.floor(value * Math.pow(10, -token.length + 3));
};
return (0, _utils.mapValue)((0, _utils.parseNDigits)(token.length, dateString), valueCallback);
}
}, {
key: "set",
value: function set(date, _flags, value) {
date.setUTCMilliseconds(value);
return date;
}
}]);
return FractionOfSecondParser;
}(_Parser2.Parser);
exports.FractionOfSecondParser = FractionOfSecondParser;

View File

@ -0,0 +1,64 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Hour0To11Parser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var Hour0To11Parser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(Hour0To11Parser, _Parser);
var _super = (0, _createSuper2.default)(Hour0To11Parser);
function Hour0To11Parser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 70);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['h', 'H', 'k', 't', 'T']);
return _this;
}
(0, _createClass2.default)(Hour0To11Parser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'K':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.hour11h, dateString);
case 'Ko':
return match.ordinalNumber(dateString, {
unit: 'hour'
});
default:
return (0, _utils.parseNDigits)(token.length, dateString);
}
}
}, {
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;
}(_Parser2.Parser);
exports.Hour0To11Parser = Hour0To11Parser;

View File

@ -0,0 +1,59 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Hour0to23Parser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var Hour0to23Parser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(Hour0to23Parser, _Parser);
var _super = (0, _createSuper2.default)(Hour0to23Parser);
function Hour0to23Parser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 70);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['a', 'b', 'h', 'K', 'k', 't', 'T']);
return _this;
}
(0, _createClass2.default)(Hour0to23Parser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'H':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.hour23h, dateString);
case 'Ho':
return match.ordinalNumber(dateString, {
unit: 'hour'
});
default:
return (0, _utils.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;
}(_Parser2.Parser);
exports.Hour0to23Parser = Hour0to23Parser;

View File

@ -0,0 +1,60 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Hour1To24Parser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var Hour1To24Parser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(Hour1To24Parser, _Parser);
var _super = (0, _createSuper2.default)(Hour1To24Parser);
function Hour1To24Parser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 70);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['a', 'b', 'h', 'H', 'K', 't', 'T']);
return _this;
}
(0, _createClass2.default)(Hour1To24Parser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'k':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.hour24h, dateString);
case 'ko':
return match.ordinalNumber(dateString, {
unit: 'hour'
});
default:
return (0, _utils.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;
}(_Parser2.Parser);
exports.Hour1To24Parser = Hour1To24Parser;

View File

@ -0,0 +1,66 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Hour1to12Parser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var Hour1to12Parser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(Hour1to12Parser, _Parser);
var _super = (0, _createSuper2.default)(Hour1to12Parser);
function Hour1to12Parser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 70);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['H', 'K', 'k', 't', 'T']);
return _this;
}
(0, _createClass2.default)(Hour1to12Parser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'h':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.hour12h, dateString);
case 'ho':
return match.ordinalNumber(dateString, {
unit: 'hour'
});
default:
return (0, _utils.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;
}(_Parser2.Parser);
exports.Hour1to12Parser = Hour1to12Parser;

View File

@ -0,0 +1,112 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ISODayParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCISODay/index.js"));
// ISO day of week
var ISODayParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ISODayParser, _Parser);
var _super = (0, _createSuper2.default)(ISODayParser);
function ISODayParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'E', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.parseNDigits)(token.length, dateString);
// 2nd
case 'io':
return match.ordinalNumber(dateString, {
unit: 'day'
});
// Tue
case 'iii':
return (0, _utils.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 (0, _utils.mapValue)(match.day(dateString, {
width: 'narrow',
context: 'formatting'
}), valueCallback);
// Tu
case 'iiiiii':
return (0, _utils.mapValue)(match.day(dateString, {
width: 'short',
context: 'formatting'
}) || match.day(dateString, {
width: 'narrow',
context: 'formatting'
}), valueCallback);
// Tuesday
case 'iiii':
default:
return (0, _utils.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 = (0, _index.default)(date, value);
date.setUTCHours(0, 0, 0, 0);
return date;
}
}]);
return ISODayParser;
}(_Parser2.Parser);
exports.ISODayParser = ISODayParser;

View File

@ -0,0 +1,60 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ISOTimezoneParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
// Timezone (ISO-8601)
var ISOTimezoneParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ISOTimezoneParser, _Parser);
var _super = (0, _createSuper2.default)(ISOTimezoneParser);
function ISOTimezoneParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 10);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['t', 'T', 'X']);
return _this;
}
(0, _createClass2.default)(ISOTimezoneParser, [{
key: "parse",
value: function parse(dateString, token) {
switch (token) {
case 'x':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basicOptionalMinutes, dateString);
case 'xx':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basic, dateString);
case 'xxxx':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basicOptionalSeconds, dateString);
case 'xxxxx':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.extendedOptionalSeconds, dateString);
case 'xxx':
default:
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.extended, dateString);
}
}
}, {
key: "set",
value: function set(date, flags, value) {
if (flags.timestampIsSet) {
return date;
}
return new Date(date.getTime() - value);
}
}]);
return ISOTimezoneParser;
}(_Parser2.Parser);
exports.ISOTimezoneParser = ISOTimezoneParser;

View File

@ -0,0 +1,60 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ISOTimezoneWithZParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
// Timezone (ISO-8601. +00:00 is `'Z'`)
var ISOTimezoneWithZParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ISOTimezoneWithZParser, _Parser);
var _super = (0, _createSuper2.default)(ISOTimezoneWithZParser);
function ISOTimezoneWithZParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 10);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['t', 'T', 'x']);
return _this;
}
(0, _createClass2.default)(ISOTimezoneWithZParser, [{
key: "parse",
value: function parse(dateString, token) {
switch (token) {
case 'X':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basicOptionalMinutes, dateString);
case 'XX':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basic, dateString);
case 'XXXX':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.basicOptionalSeconds, dateString);
case 'XXXXX':
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.extendedOptionalSeconds, dateString);
case 'XXX':
default:
return (0, _utils.parseTimezonePattern)(_constants.timezonePatterns.extended, dateString);
}
}
}, {
key: "set",
value: function set(date, flags, value) {
if (flags.timestampIsSet) {
return date;
}
return new Date(date.getTime() - value);
}
}]);
return ISOTimezoneWithZParser;
}(_Parser2.Parser);
exports.ISOTimezoneWithZParser = ISOTimezoneWithZParser;

View File

@ -0,0 +1,61 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ISOWeekParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCISOWeek/index.js"));
var _index2 = _interopRequireDefault(require("../../../_lib/startOfUTCISOWeek/index.js"));
// ISO week of year
var ISOWeekParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ISOWeekParser, _Parser);
var _super = (0, _createSuper2.default)(ISOWeekParser);
function ISOWeekParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 100);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(ISOWeekParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'I':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.week, dateString);
case 'Io':
return match.ordinalNumber(dateString, {
unit: 'week'
});
default:
return (0, _utils.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 (0, _index2.default)((0, _index.default)(date, value));
}
}]);
return ISOWeekParser;
}(_Parser2.Parser);
exports.ISOWeekParser = ISOWeekParser;

View File

@ -0,0 +1,51 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ISOWeekYearParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/startOfUTCISOWeek/index.js"));
// ISO week-numbering year
var ISOWeekYearParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(ISOWeekYearParser, _Parser);
var _super = (0, _createSuper2.default)(ISOWeekYearParser);
function ISOWeekYearParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 130);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['G', 'y', 'Y', 'u', 'Q', 'q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(ISOWeekYearParser, [{
key: "parse",
value: function parse(dateString, token) {
if (token === 'R') {
return (0, _utils.parseNDigitsSigned)(4, dateString);
}
return (0, _utils.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 (0, _index.default)(firstWeekOfYear);
}
}]);
return ISOWeekYearParser;
}(_Parser2.Parser);
exports.ISOWeekYearParser = ISOWeekYearParser;

View File

@ -0,0 +1,110 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LocalDayParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCDay/index.js"));
// Local day of week
var LocalDayParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(LocalDayParser, _Parser);
var _super = (0, _createSuper2.default)(LocalDayParser);
function LocalDayParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNDigits)(token.length, dateString), valueCallback);
// 3rd
case 'eo':
return (0, _utils.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 = (0, _index.default)(date, value, options);
date.setUTCHours(0, 0, 0, 0);
return date;
}
}]);
return LocalDayParser;
}(_Parser2.Parser);
exports.LocalDayParser = LocalDayParser;

View File

@ -0,0 +1,61 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LocalWeekParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCWeek/index.js"));
var _index2 = _interopRequireDefault(require("../../../_lib/startOfUTCWeek/index.js"));
// Local week of year
var LocalWeekParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(LocalWeekParser, _Parser);
var _super = (0, _createSuper2.default)(LocalWeekParser);
function LocalWeekParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 100);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);
return _this;
}
(0, _createClass2.default)(LocalWeekParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'w':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.week, dateString);
case 'wo':
return match.ordinalNumber(dateString, {
unit: 'week'
});
default:
return (0, _utils.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 (0, _index2.default)((0, _index.default)(date, value, options), options);
}
}]);
return LocalWeekParser;
}(_Parser2.Parser);
exports.LocalWeekParser = LocalWeekParser;

View File

@ -0,0 +1,76 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LocalWeekYearParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/getUTCWeekYear/index.js"));
var _index2 = _interopRequireDefault(require("../../../_lib/startOfUTCWeek/index.js"));
// Local week-numbering year
var LocalWeekYearParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(LocalWeekYearParser, _Parser);
var _super = (0, _createSuper2.default)(LocalWeekYearParser);
function LocalWeekYearParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 130);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'R', 'u', 'Q', 'q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNDigits)(4, dateString), valueCallback);
case 'Yo':
return (0, _utils.mapValue)(match.ordinalNumber(dateString, {
unit: 'year'
}), valueCallback);
default:
return (0, _utils.mapValue)((0, _utils.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 = (0, _index.default)(date, options);
if (value.isTwoDigitYear) {
var normalizedTwoDigitYear = (0, _utils.normalizeTwoDigitYear)(value.year, currentYear);
date.setUTCFullYear(normalizedTwoDigitYear, 0, options.firstWeekContainsDate);
date.setUTCHours(0, 0, 0, 0);
return (0, _index2.default)(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 (0, _index2.default)(date, options);
}
}]);
return LocalWeekYearParser;
}(_Parser2.Parser);
exports.LocalWeekYearParser = LocalWeekYearParser;

View File

@ -0,0 +1,59 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MinuteParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var MinuteParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(MinuteParser, _Parser);
var _super = (0, _createSuper2.default)(MinuteParser);
function MinuteParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 60);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['t', 'T']);
return _this;
}
(0, _createClass2.default)(MinuteParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 'm':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.minute, dateString);
case 'mo':
return match.ordinalNumber(dateString, {
unit: 'minute'
});
default:
return (0, _utils.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;
}(_Parser2.Parser);
exports.MinuteParser = MinuteParser;

View File

@ -0,0 +1,94 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MonthParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _utils = require("../utils.js");
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var MonthParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(MonthParser, _Parser);
var _super = (0, _createSuper2.default)(MonthParser);
function MonthParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'L', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 110);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNumericPattern)(_constants.numericPatterns.month, dateString), valueCallback);
// 01, 02, ..., 12
case 'MM':
return (0, _utils.mapValue)((0, _utils.parseNDigits)(2, dateString), valueCallback);
// 1st, 2nd, ..., 12th
case 'Mo':
return (0, _utils.mapValue)(match.ordinalNumber(dateString, {
unit: 'month'
}), valueCallback);
// Jan, Feb, ..., Dec
case 'MMM':
return match.month(dateString, {
width: 'abbreviated',
context: 'formatting'
}) || match.month(dateString, {
width: 'narrow',
context: 'formatting'
});
// J, F, ..., D
case 'MMMMM':
return match.month(dateString, {
width: 'narrow',
context: 'formatting'
});
// January, February, ..., December
case 'MMMM':
default:
return match.month(dateString, {
width: 'wide',
context: 'formatting'
}) || match.month(dateString, {
width: 'abbreviated',
context: 'formatting'
}) || match.month(dateString, {
width: 'narrow',
context: 'formatting'
});
}
}
}, {
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;
}(_Parser2.Parser);
exports.MonthParser = MonthParser;

View File

@ -0,0 +1,89 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.QuarterParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var QuarterParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(QuarterParser, _Parser);
var _super = (0, _createSuper2.default)(QuarterParser);
function QuarterParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 120);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(QuarterParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
// 1, 2, 3, 4
case 'Q':
case 'QQ':
// 01, 02, 03, 04
return (0, _utils.parseNDigits)(token.length, dateString);
// 1st, 2nd, 3rd, 4th
case 'Qo':
return match.ordinalNumber(dateString, {
unit: 'quarter'
});
// Q1, Q2, Q3, Q4
case 'QQQ':
return match.quarter(dateString, {
width: 'abbreviated',
context: 'formatting'
}) || match.quarter(dateString, {
width: 'narrow',
context: 'formatting'
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case 'QQQQQ':
return match.quarter(dateString, {
width: 'narrow',
context: 'formatting'
});
// 1st quarter, 2nd quarter, ...
case 'QQQQ':
default:
return match.quarter(dateString, {
width: 'wide',
context: 'formatting'
}) || match.quarter(dateString, {
width: 'abbreviated',
context: 'formatting'
}) || match.quarter(dateString, {
width: 'narrow',
context: 'formatting'
});
}
}
}, {
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;
}(_Parser2.Parser);
exports.QuarterParser = QuarterParser;

View File

@ -0,0 +1,59 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SecondParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var SecondParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(SecondParser, _Parser);
var _super = (0, _createSuper2.default)(SecondParser);
function SecondParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 50);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['t', 'T']);
return _this;
}
(0, _createClass2.default)(SecondParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
case 's':
return (0, _utils.parseNumericPattern)(_constants.numericPatterns.second, dateString);
case 'so':
return match.ordinalNumber(dateString, {
unit: 'second'
});
default:
return (0, _utils.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;
}(_Parser2.Parser);
exports.SecondParser = SecondParser;

View File

@ -0,0 +1,110 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StandAloneLocalDayParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var _index = _interopRequireDefault(require("../../../_lib/setUTCDay/index.js"));
// Stand-alone local day of week
var StandAloneLocalDayParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(StandAloneLocalDayParser, _Parser);
var _super = (0, _createSuper2.default)(StandAloneLocalDayParser);
function StandAloneLocalDayParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 90);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNDigits)(token.length, dateString), valueCallback);
// 3rd
case 'co':
return (0, _utils.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 = (0, _index.default)(date, value, options);
date.setUTCHours(0, 0, 0, 0);
return date;
}
}]);
return StandAloneLocalDayParser;
}(_Parser2.Parser);
exports.StandAloneLocalDayParser = StandAloneLocalDayParser;

View File

@ -0,0 +1,94 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StandAloneMonthParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _constants = require("../constants.js");
var _utils = require("../utils.js");
var StandAloneMonthParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(StandAloneMonthParser, _Parser);
var _super = (0, _createSuper2.default)(StandAloneMonthParser);
function StandAloneMonthParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 110);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNumericPattern)(_constants.numericPatterns.month, dateString), valueCallback);
// 01, 02, ..., 12
case 'LL':
return (0, _utils.mapValue)((0, _utils.parseNDigits)(2, dateString), valueCallback);
// 1st, 2nd, ..., 12th
case 'Lo':
return (0, _utils.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;
}(_Parser2.Parser);
exports.StandAloneMonthParser = StandAloneMonthParser;

View File

@ -0,0 +1,89 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StandAloneQuarterParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var StandAloneQuarterParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(StandAloneQuarterParser, _Parser);
var _super = (0, _createSuper2.default)(StandAloneQuarterParser);
function StandAloneQuarterParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 120);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(StandAloneQuarterParser, [{
key: "parse",
value: function parse(dateString, token, match) {
switch (token) {
// 1, 2, 3, 4
case 'q':
case 'qq':
// 01, 02, 03, 04
return (0, _utils.parseNDigits)(token.length, dateString);
// 1st, 2nd, 3rd, 4th
case 'qo':
return match.ordinalNumber(dateString, {
unit: 'quarter'
});
// Q1, Q2, Q3, Q4
case 'qqq':
return match.quarter(dateString, {
width: 'abbreviated',
context: '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;
}(_Parser2.Parser);
exports.StandAloneQuarterParser = StandAloneQuarterParser;

View File

@ -0,0 +1,45 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TimestampMillisecondsParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(TimestampMillisecondsParser, _Parser);
var _super = (0, _createSuper2.default)(TimestampMillisecondsParser);
function TimestampMillisecondsParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 20);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", '*');
return _this;
}
(0, _createClass2.default)(TimestampMillisecondsParser, [{
key: "parse",
value: function parse(dateString) {
return (0, _utils.parseAnyDigitsSigned)(dateString);
}
}, {
key: "set",
value: function set(_date, _flags, value) {
return [new Date(value), {
timestampIsSet: true
}];
}
}]);
return TimestampMillisecondsParser;
}(_Parser2.Parser);
exports.TimestampMillisecondsParser = TimestampMillisecondsParser;

View File

@ -0,0 +1,45 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TimestampSecondsParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../utils.js");
var TimestampSecondsParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(TimestampSecondsParser, _Parser);
var _super = (0, _createSuper2.default)(TimestampSecondsParser);
function TimestampSecondsParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 40);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", '*');
return _this;
}
(0, _createClass2.default)(TimestampSecondsParser, [{
key: "parse",
value: function parse(dateString) {
return (0, _utils.parseAnyDigitsSigned)(dateString);
}
}, {
key: "set",
value: function set(_date, _flags, value) {
return [new Date(value * 1000), {
timestampIsSet: true
}];
}
}]);
return TimestampSecondsParser;
}(_Parser2.Parser);
exports.TimestampSecondsParser = TimestampSecondsParser;

View File

@ -0,0 +1,81 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.YearParser = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Parser2 = require("../Parser.js");
var _utils = require("../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 |
var YearParser = /*#__PURE__*/function (_Parser) {
(0, _inherits2.default)(YearParser, _Parser);
var _super = (0, _createSuper2.default)(YearParser);
function YearParser() {
var _this;
(0, _classCallCheck2.default)(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));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "priority", 130);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "incompatibleTokens", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']);
return _this;
}
(0, _createClass2.default)(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 (0, _utils.mapValue)((0, _utils.parseNDigits)(4, dateString), valueCallback);
case 'yo':
return (0, _utils.mapValue)(match.ordinalNumber(dateString, {
unit: 'year'
}), valueCallback);
default:
return (0, _utils.mapValue)((0, _utils.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 = (0, _utils.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;
}(_Parser2.Parser);
exports.YearParser = YearParser;

114
mc_test/node_modules/date-fns/parse/_lib/parsers/index.js generated vendored Executable file
View File

@ -0,0 +1,114 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parsers = void 0;
var _EraParser = require("./EraParser.js");
var _YearParser = require("./YearParser.js");
var _LocalWeekYearParser = require("./LocalWeekYearParser.js");
var _ISOWeekYearParser = require("./ISOWeekYearParser.js");
var _ExtendedYearParser = require("./ExtendedYearParser.js");
var _QuarterParser = require("./QuarterParser.js");
var _StandAloneQuarterParser = require("./StandAloneQuarterParser.js");
var _MonthParser = require("./MonthParser.js");
var _StandAloneMonthParser = require("./StandAloneMonthParser.js");
var _LocalWeekParser = require("./LocalWeekParser.js");
var _ISOWeekParser = require("./ISOWeekParser.js");
var _DateParser = require("./DateParser.js");
var _DayOfYearParser = require("./DayOfYearParser.js");
var _DayParser = require("./DayParser.js");
var _LocalDayParser = require("./LocalDayParser.js");
var _StandAloneLocalDayParser = require("./StandAloneLocalDayParser.js");
var _ISODayParser = require("./ISODayParser.js");
var _AMPMParser = require("./AMPMParser.js");
var _AMPMMidnightParser = require("./AMPMMidnightParser.js");
var _DayPeriodParser = require("./DayPeriodParser.js");
var _Hour1to12Parser = require("./Hour1to12Parser.js");
var _Hour0to23Parser = require("./Hour0to23Parser.js");
var _Hour0To11Parser = require("./Hour0To11Parser.js");
var _Hour1To24Parser = require("./Hour1To24Parser.js");
var _MinuteParser = require("./MinuteParser.js");
var _SecondParser = require("./SecondParser.js");
var _FractionOfSecondParser = require("./FractionOfSecondParser.js");
var _ISOTimezoneWithZParser = require("./ISOTimezoneWithZParser.js");
var _ISOTimezoneParser = require("./ISOTimezoneParser.js");
var _TimestampSecondsParser = require("./TimestampSecondsParser.js");
var _TimestampMillisecondsParser = require("./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.
*/
var parsers = {
G: new _EraParser.EraParser(),
y: new _YearParser.YearParser(),
Y: new _LocalWeekYearParser.LocalWeekYearParser(),
R: new _ISOWeekYearParser.ISOWeekYearParser(),
u: new _ExtendedYearParser.ExtendedYearParser(),
Q: new _QuarterParser.QuarterParser(),
q: new _StandAloneQuarterParser.StandAloneQuarterParser(),
M: new _MonthParser.MonthParser(),
L: new _StandAloneMonthParser.StandAloneMonthParser(),
w: new _LocalWeekParser.LocalWeekParser(),
I: new _ISOWeekParser.ISOWeekParser(),
d: new _DateParser.DateParser(),
D: new _DayOfYearParser.DayOfYearParser(),
E: new _DayParser.DayParser(),
e: new _LocalDayParser.LocalDayParser(),
c: new _StandAloneLocalDayParser.StandAloneLocalDayParser(),
i: new _ISODayParser.ISODayParser(),
a: new _AMPMParser.AMPMParser(),
b: new _AMPMMidnightParser.AMPMMidnightParser(),
B: new _DayPeriodParser.DayPeriodParser(),
h: new _Hour1to12Parser.Hour1to12Parser(),
H: new _Hour0to23Parser.Hour0to23Parser(),
K: new _Hour0To11Parser.Hour0To11Parser(),
k: new _Hour1To24Parser.Hour1To24Parser(),
m: new _MinuteParser.MinuteParser(),
s: new _SecondParser.SecondParser(),
S: new _FractionOfSecondParser.FractionOfSecondParser(),
X: new _ISOTimezoneWithZParser.ISOTimezoneWithZParser(),
x: new _ISOTimezoneParser.ISOTimezoneParser(),
t: new _TimestampSecondsParser.TimestampSecondsParser(),
T: new _TimestampMillisecondsParser.TimestampMillisecondsParser()
};
exports.parsers = parsers;