mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: fix hour 0 parsing, remove unused function (#18897)
This commit is contained in:
@@ -58,18 +58,6 @@ fn (mut p DateTimeParser) must_be_int_with_minimum_length(min int, max int, allo
|
||||
return val.int()
|
||||
}
|
||||
|
||||
fn (mut p DateTimeParser) must_be_single_int_with_optional_leading_zero() !int {
|
||||
mut val := p.next(1)!
|
||||
if val == '0' {
|
||||
next := p.next(1) or { '' }
|
||||
if !next.contains_only('0123456789') {
|
||||
return error('expected int, found: ${next}')
|
||||
}
|
||||
val += next
|
||||
}
|
||||
return val.int()
|
||||
}
|
||||
|
||||
fn (mut p DateTimeParser) must_be_string(must string) ! {
|
||||
val := p.next(must.len)!
|
||||
if val != must {
|
||||
@@ -203,7 +191,7 @@ fn (mut p DateTimeParser) parse() !Time {
|
||||
}
|
||||
}
|
||||
'H' {
|
||||
hour_ = p.must_be_int_with_minimum_length(1, 2, false) or {
|
||||
hour_ = p.must_be_int_with_minimum_length(1, 2, true) or {
|
||||
return error_invalid_time(0, 'end of string reached before hours where specified')
|
||||
}
|
||||
if hour_ < 0 || hour_ > 23 {
|
||||
@@ -219,7 +207,7 @@ fn (mut p DateTimeParser) parse() !Time {
|
||||
}
|
||||
}
|
||||
'h' {
|
||||
hour_ = p.must_be_int_with_minimum_length(1, 2, false) or {
|
||||
hour_ = p.must_be_int_with_minimum_length(1, 2, true) or {
|
||||
return error_invalid_time(0, 'end of string reached before hours where specified')
|
||||
}
|
||||
if hour_ < 0 || hour_ > 23 {
|
||||
|
||||
Reference in New Issue
Block a user