Fix times' parse with literal strings

This commit is contained in:
Magnus Holm
2015-07-24 18:08:05 +02:00
parent 4932415742
commit fdf454e3ae

View File

@@ -1020,10 +1020,10 @@ proc parse*(value, layout: string): TimeInfo =
# These are literals in both the layout and the value string
if layout[i] == '\'':
inc(i)
inc(j)
while layout[i] != '\'' and layout.len-1 > i:
inc(i)
inc(j)
inc(i)
else:
inc(i)
inc(j)
@@ -1112,6 +1112,8 @@ when isMainModule:
s = "2006-01-12T15:04:05Z-07:00"
f = "yyyy-MM-ddTHH:mm:ssZzzz"
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
f = "yyyy-MM-dd'T'HH:mm:ss'Z'zzz"
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
# RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
s = "2006-01-12T15:04:05.999999999Z-07:00"
f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"