start modularisation and breaking down the monofile

This commit is contained in:
Alphons Joseph
2025-03-12 21:45:23 +08:00
parent 3c65e6d6c5
commit c9f0f9cf16
25 changed files with 2284 additions and 2192 deletions
+21
View File
@@ -0,0 +1,21 @@
export function convertTo12HourFormat(
time: string,
noMinutes: boolean = false,
): string {
let [hours, minutes] = time.split(":").map(Number)
let period = "AM"
if (hours >= 12) {
period = "PM"
if (hours > 12) hours -= 12
} else if (hours === 0) {
hours = 12
}
let hoursStr = hours.toString()
if (hoursStr.length === 2 && hoursStr.startsWith("0")) {
hoursStr = hoursStr.substring(1)
}
return `${hoursStr}${noMinutes ? "" : `:${minutes.toString().padStart(2, "0")}`} ${period}`
}