mirror of
https://github.com/vlang/v.git
synced 2025-09-22 11:57:33 -04:00
This commit is contained in:
parent
b2a985170d
commit
c088cbdbd5
@ -1420,6 +1420,14 @@ pub fn (mut p Parser) date_time() !ast.DateTimeType {
|
||||
if p.tok.lit.starts_with('T') || p.tok.lit.starts_with('t') {
|
||||
lit += p.tok.lit[0].ascii_str() //'T' or 't'
|
||||
} else {
|
||||
peek := p.peek(0)!
|
||||
if peek.kind != .number {
|
||||
// return early as date for strings yyyy-mm-dd_X... (_ is space, X is not numeric)
|
||||
return ast.Date{
|
||||
text: lit
|
||||
pos: pos
|
||||
}
|
||||
}
|
||||
lit += p.tok.lit
|
||||
p.next()!
|
||||
}
|
||||
|
@ -326,3 +326,14 @@ fn test_unsupported_type() {
|
||||
assert err.msg() == 'Doc.decode: expected struct, found string'
|
||||
}
|
||||
}
|
||||
|
||||
fn test_date_array_decode_with_spaces() {
|
||||
// test space after yyyy-mm-dd is not date-time separator but white to consume. issue # 25279
|
||||
s := '
|
||||
dates = [ 1979-05-27 , 2022-12-31 ]
|
||||
'
|
||||
a := Arrs{
|
||||
dates: [toml.Date{'1979-05-27'}, toml.Date{'2022-12-31'}]
|
||||
}
|
||||
assert toml.decode[Arrs](s)! == a
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user