mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
start modularisation and breaking down the monofile
This commit is contained in:
@@ -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}`
|
||||
}
|
||||
Reference in New Issue
Block a user