wip:milestone 0 fixes
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

This commit is contained in:
2026-03-15 12:35:42 +02:00
parent 6708cf28a7
commit cffdf8af86
61266 changed files with 4511646 additions and 1938 deletions

View File

@@ -0,0 +1,43 @@
"use strict";
exports.Hour1to12Parser = void 0;
var _constants = require("../constants.js");
var _Parser = require("../Parser.js");
var _utils = require("../utils.js");
class Hour1to12Parser extends _Parser.Parser {
priority = 70;
parse(dateString, token, match) {
switch (token) {
case "h":
return (0, _utils.parseNumericPattern)(
_constants.numericPatterns.hour12h,
dateString,
);
case "ho":
return match.ordinalNumber(dateString, { unit: "hour" });
default:
return (0, _utils.parseNDigits)(token.length, dateString);
}
}
validate(_date, value) {
return value >= 1 && value <= 12;
}
set(date, _flags, value) {
const isPM = date.getHours() >= 12;
if (isPM && value < 12) {
date.setHours(value + 12, 0, 0, 0);
} else if (!isPM && value === 12) {
date.setHours(0, 0, 0, 0);
} else {
date.setHours(value, 0, 0, 0);
}
return date;
}
incompatibleTokens = ["H", "K", "k", "t", "T"];
}
exports.Hour1to12Parser = Hour1to12Parser;