fix ts errors
This commit is contained in:
parent
9649666195
commit
3eef4c2a0e
|
|
@ -86,9 +86,9 @@ function parseTime(s: string): { hour: number, minute: number } | null {
|
|||
// 12h: "7am", "7pm", "7:30am", "7:30pm", "12am", "12:00pm"
|
||||
const m12 = s.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)$/i)
|
||||
if (m12) {
|
||||
let hour = parseInt(m12[1])
|
||||
let hour = parseInt(m12[1]!)
|
||||
const minute = m12[2] ? parseInt(m12[2]) : 0
|
||||
const period = m12[3].toLowerCase()
|
||||
const period = m12[3]!.toLowerCase()
|
||||
if (hour < 1 || hour > 12 || minute > 59) return null
|
||||
if (period === 'am' && hour === 12) hour = 0
|
||||
else if (period === 'pm' && hour !== 12) hour += 12
|
||||
|
|
@ -98,8 +98,8 @@ function parseTime(s: string): { hour: number, minute: number } | null {
|
|||
// 24h: "14:00", "0:00", "23:59"
|
||||
const m24 = s.match(/^(\d{1,2}):(\d{2})$/)
|
||||
if (m24) {
|
||||
const hour = parseInt(m24[1])
|
||||
const minute = parseInt(m24[2])
|
||||
const hour = parseInt(m24[1]!)
|
||||
const minute = parseInt(m24[2]!)
|
||||
if (hour > 23 || minute > 59) return null
|
||||
return { hour, minute }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user