feat: apply 12 hour time to timetable #280

This commit is contained in:
SethBurkart123
2025-06-04 15:44:51 +10:00
parent f62d712549
commit 6c12f5cf00
3 changed files with 62 additions and 6 deletions
+3 -3
View File
@@ -3,10 +3,10 @@ export function convertTo12HourFormat(
noMinutes: boolean = false,
): string {
let [hours, minutes] = time.split(":").map(Number);
let period = "AM";
let period = "am";
if (hours >= 12) {
period = "PM";
period = "pm";
if (hours > 12) hours -= 12;
} else if (hours === 0) {
hours = 12;
@@ -17,5 +17,5 @@ export function convertTo12HourFormat(
hoursStr = hoursStr.substring(1);
}
return `${hoursStr}${noMinutes ? "" : `:${minutes.toString().padStart(2, "0")}`} ${period}`;
return `${hoursStr}${noMinutes ? "" : `:${minutes.toString().padStart(2, "0")}`}${period}`;
}