v1.0 with SW PWA enabled

This commit is contained in:
Blomios
2026-01-01 17:40:53 +01:00
parent 1c0e22aac1
commit 3c8bebb2ad
29775 changed files with 2197201 additions and 119080 deletions

View File

@ -0,0 +1,54 @@
import { Parser } from "../Parser.mjs";
import { dayPeriodEnumToHours } from "../utils.mjs";
// 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"];
}