- (m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0))) &&
- ((hr <= 23 && min <= 59 && sec <= 59) ||
- // leap second
- (hr - tzH === 23 && min - tzM === 59 && sec === 60))
+ (m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0)))
+ )
+}
+
+function validTime(str: string): boolean {
+ const matches: string[] | null = TIME.exec(str)
+ if (!matches) return false
+ const hr: number = +matches[1]
+ const min: number = +matches[2]
+ const sec: number = +matches[3]
+ const tzH: number = +(matches[4] || 0)
+ const tzM: number = +(matches[5] || 0)
+ return (
+ (hr <= 23 && min <= 59 && sec <= 59) ||
+ // leap second
+ (hr - tzH === 23 && min - tzM === 59 && sec === 60)