Flipped logic on 12hr

master
stweedo 2023-05-11 13:26:22 -05:00 committed by GitHub
parent f89de44dfa
commit 22bd23178c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -202,13 +202,11 @@
function formatTime(date, leadingZero) {
let hours = date.getHours();
let minutes = date.getMinutes();
// If 12 hour format is selected, adjust hours
if (!is12Hour) {
if (is12Hour) {
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12' in 12h format
}
let formattedHours = leadingZero && hours < 10 ? `0${hours}` : `${hours}`;
let formattedMinutes = minutes < 10 ? `0${minutes}` : `${minutes}`;
return `${formattedHours}:${formattedMinutes}`;