remove need for hardcoded 12am test

This commit is contained in:
2024-05-23 20:29:05 -05:00
parent 98418014d3
commit 834aafe06d
+7 -6
View File
@@ -85,8 +85,13 @@ function inferSeparators(value: string, isAM: boolean, isPM: boolean) {
}
} else if (length === 2) {
if (isPM || isAM) {
inferredMillis = parse(value) * MILLIS_PER_HOUR;
if (isAM || (isPM && value === '12')) {
if (value === '12' && isAM) {
inferredMillis = 0;
} else {
inferredMillis = parse(value) * MILLIS_PER_HOUR;
}
if (isAM || value === '12') {
// this ensures we dont add 12 hours in the end
addAM = 12;
}
@@ -114,10 +119,6 @@ function inferSeparators(value: string, isAM: boolean, isPM: boolean) {
export const forgivingStringToMillis = (value: string): number => {
value = value.toLowerCase();
if (value === '12am' || value === '12a') {
return 0;
}
const { isAM, isPM, value: parsingValue } = checkAmPm(value);
const maybeMillisFromMatchers = checkMatchers(parsingValue);
if (maybeMillisFromMatchers !== null) {