- OpenAPI: add missing endpoints (add-from-url, subscriptions, public availability) - OpenAPI: CalendarSubscription schema, Subscriptions tag - Frontend app - Migrations: count_for_availability, subscriptions_sync, user_preferences, calendar_settings - Config, rate limit, auth, calendar, booking, ICS, availability, user service updates Made-with: Cursor
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import { Parser } from "../Parser.js";
|
|
|
|
import { dayPeriodEnumToHours } from "../utils.js";
|
|
|
|
// in the morning, in the afternoon, in the evening, at night
|
|
export class DayPeriodParser extends Parser {
|
|
priority = 80;
|
|
|
|
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",
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
set(date, _flags, value) {
|
|
date.setHours(dayPeriodEnumToHours(value), 0, 0, 0);
|
|
return date;
|
|
}
|
|
|
|
incompatibleTokens = ["a", "b", "t", "T"];
|
|
}
|