Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
"use strict";
|
|
exports.DayPeriodParser = void 0;
|
|
var _Parser = require("../Parser.js");
|
|
|
|
var _utils = require("../utils.js");
|
|
|
|
// in the morning, in the afternoon, in the evening, at night
|
|
class DayPeriodParser extends _Parser.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((0, _utils.dayPeriodEnumToHours)(value), 0, 0, 0);
|
|
return date;
|
|
}
|
|
|
|
incompatibleTokens = ["a", "b", "t", "T"];
|
|
}
|
|
exports.DayPeriodParser = DayPeriodParser;
|