mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 15:45:27 +03:00
simplify hour calculation
This commit is contained in:
parent
698833ef6c
commit
1f78e9ae44
@ -82,14 +82,9 @@ export function useFormattedHour(
|
|||||||
const [hour, minute] = time.includes(":") ? time.split(":") : [time, "00"];
|
const [hour, minute] = time.includes(":") ? time.split(":") : [time, "00"];
|
||||||
const hourNum = parseInt(hour);
|
const hourNum = parseInt(hour);
|
||||||
|
|
||||||
if (hourNum < 12) {
|
const adjustedHour = hourNum % 12 || 12;
|
||||||
if (hourNum == 0) {
|
const period = hourNum < 12 ? "AM" : "PM";
|
||||||
return `12:${minute} AM`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${hourNum}:${minute} AM`;
|
return `${adjustedHour}:${minute} ${period}`;
|
||||||
} else {
|
|
||||||
return `${hourNum - 12}:${minute} PM`;
|
|
||||||
}
|
|
||||||
}, [hour24, time]);
|
}, [hour24, time]);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user