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

time: fix failing test_iso8601_parse_utc

This commit is contained in:
Delyan Angelov 2020-12-09 15:48:21 +02:00
parent 338f3afd31
commit ada02d4498
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -5,9 +5,7 @@ module time
// parse returns time from a date string in "YYYY-MM-DD HH:MM:SS" format. // parse returns time from a date string in "YYYY-MM-DD HH:MM:SS" format.
pub fn parse(s string) ?Time { pub fn parse(s string) ?Time {
pos := s.index(' ') or { pos := s.index(' ') or { return error('Invalid time format: $s') }
return error('Invalid time format: $s')
}
symd := s[..pos] symd := s[..pos]
ymd := symd.split('-') ymd := symd.split('-')
if ymd.len != 3 { if ymd.len != 3 {
@ -35,9 +33,7 @@ pub fn parse_rfc2822(s string) ?Time {
if fields.len < 5 { if fields.len < 5 {
return error('Invalid time format: $s') return error('Invalid time format: $s')
} }
pos := months_string.index(fields[2]) or { pos := months_string.index(fields[2]) or { return error('Invalid time format: $s') }
return error('Invalid time format: $s')
}
mm := pos / 3 + 1 mm := pos / 3 + 1
mut tmstr := byteptr(0) mut tmstr := byteptr(0)
unsafe { unsafe {
@ -95,6 +91,9 @@ pub fn parse_iso8601(s string) ?Time {
second: second second: second
microsecond: mic_second microsecond: mic_second
}) })
if is_utc {
return t
}
if is_local_time { if is_local_time {
return to_local_time(t) return to_local_time(t)
} }