1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- "use strict";
- exports.DayParser = void 0;
- var _index = require("../../../setDay.cjs");
- var _Parser = require("../Parser.cjs");
- // Day of week
- class DayParser extends _Parser.Parser {
- priority = 90;
- 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" })
- );
- }
- }
- validate(_date, value) {
- return value >= 0 && value <= 6;
- }
- set(date, _flags, value, options) {
- date = (0, _index.setDay)(date, value, options);
- date.setHours(0, 0, 0, 0);
- return date;
- }
- incompatibleTokens = ["D", "i", "e", "c", "t", "T"];
- }
- exports.DayParser = DayParser;
|