/* eslint-disable eslint-comments/no-unlimited-disable */ /* eslint-disable */ // @ts-nocheck import type { LocaleDayPeriod, Match } from '../../../locale/types.ts'; import { Parser } from '../Parser.ts'; import type { ParseFlags, ParseResult } from '../types.ts'; import { dayPeriodEnumToHours } from '../utils.ts'; // in the morning, in the afternoon, in the evening, at night export class DayPeriodParser extends Parser { priority = 80; parse(dateString: string, token: string, match: Match): ParseResult { 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', }) ); } } set(date: DateType, _flags: ParseFlags, value: LocaleDayPeriod): DateType { date.setHours(dayPeriodEnumToHours(value), 0, 0, 0); return date; } incompatibleTokens: string[] = ['a', 'b', 't', 'T']; } /* eslint-enable */