mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
time: fix parse_format
with YY
(#18887)
This commit is contained in:
parent
2eea59c4cc
commit
bf98f7c9ee
@ -163,7 +163,7 @@ fn (mut p DateTimeParser) parse() !Time {
|
||||
}
|
||||
}
|
||||
'YY' {
|
||||
year_ = p.must_be_int(2) or {
|
||||
year_ = now().year / 100 * 100 + p.must_be_int(2) or {
|
||||
return error_invalid_time(0, 'end of string reached before the full year was specified')
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,6 @@ fn test_parse_format() {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
|
||||
assert t.year == 2018 && t.month == 1 && t.day == 27 && t.hour == 12 && t.minute == 48
|
||||
&& t.second == 34
|
||||
|
||||
@ -222,8 +221,8 @@ fn test_parse_format() {
|
||||
assert t.year == 2018 && t.month == 11 && t.day == 27 && t.hour == 12 && t.minute == 48
|
||||
&& t.second == 20
|
||||
|
||||
s = '2018-1-2 1:8:2'
|
||||
t = time.parse_format(s, 'YYYY-M-D H:m:s') or {
|
||||
s = '18-1-2 1:8:2'
|
||||
t = time.parse_format(s, 'YY-M-D H:m:s') or {
|
||||
eprintln('> failing format: ${s} | err: ${err}')
|
||||
assert false
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user