mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-26 09:29:10 +00:00
remove need for hardcoded 12am test
This commit is contained in:
@@ -85,8 +85,13 @@ function inferSeparators(value: string, isAM: boolean, isPM: boolean) {
|
|||||||
}
|
}
|
||||||
} else if (length === 2) {
|
} else if (length === 2) {
|
||||||
if (isPM || isAM) {
|
if (isPM || isAM) {
|
||||||
inferredMillis = parse(value) * MILLIS_PER_HOUR;
|
if (value === '12' && isAM) {
|
||||||
if (isAM || (isPM && value === '12')) {
|
inferredMillis = 0;
|
||||||
|
} else {
|
||||||
|
inferredMillis = parse(value) * MILLIS_PER_HOUR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAM || value === '12') {
|
||||||
// this ensures we dont add 12 hours in the end
|
// this ensures we dont add 12 hours in the end
|
||||||
addAM = 12;
|
addAM = 12;
|
||||||
}
|
}
|
||||||
@@ -114,10 +119,6 @@ function inferSeparators(value: string, isAM: boolean, isPM: boolean) {
|
|||||||
export const forgivingStringToMillis = (value: string): number => {
|
export const forgivingStringToMillis = (value: string): number => {
|
||||||
value = value.toLowerCase();
|
value = value.toLowerCase();
|
||||||
|
|
||||||
if (value === '12am' || value === '12a') {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { isAM, isPM, value: parsingValue } = checkAmPm(value);
|
const { isAM, isPM, value: parsingValue } = checkAmPm(value);
|
||||||
const maybeMillisFromMatchers = checkMatchers(parsingValue);
|
const maybeMillisFromMatchers = checkMatchers(parsingValue);
|
||||||
if (maybeMillisFromMatchers !== null) {
|
if (maybeMillisFromMatchers !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user