1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: do not panic for time.parse("2020-02-02 20.02.20")!, just return an error instead (fix #16779)

This commit is contained in:
Delyan Angelov
2022-12-27 12:58:43 +02:00
parent 6b3f8f519d
commit 508bfbf892
2 changed files with 13 additions and 7 deletions

View File

@@ -70,6 +70,9 @@ pub fn parse(s string) !Time {
}
shms := s[pos..]
hms := shms.split(':')
if hms.len != 3 {
return error_invalid_time(9)
}
hour_ := hms[0][1..]
minute_ := hms[1]
second_ := hms[2]