Merge pull request #3145 from judofyr/times-parse-literal
Fix times' parse with literal strings
This commit is contained in:
commit
903452e96e
1 changed files with 3 additions and 1 deletions
|
|
@ -1020,10 +1020,10 @@ proc parse*(value, layout: string): TimeInfo =
|
||||||
# These are literals in both the layout and the value string
|
# These are literals in both the layout and the value string
|
||||||
if layout[i] == '\'':
|
if layout[i] == '\'':
|
||||||
inc(i)
|
inc(i)
|
||||||
inc(j)
|
|
||||||
while layout[i] != '\'' and layout.len-1 > i:
|
while layout[i] != '\'' and layout.len-1 > i:
|
||||||
inc(i)
|
inc(i)
|
||||||
inc(j)
|
inc(j)
|
||||||
|
inc(i)
|
||||||
else:
|
else:
|
||||||
inc(i)
|
inc(i)
|
||||||
inc(j)
|
inc(j)
|
||||||
|
|
@ -1112,6 +1112,8 @@ when isMainModule:
|
||||||
s = "2006-01-12T15:04:05Z-07:00"
|
s = "2006-01-12T15:04:05Z-07:00"
|
||||||
f = "yyyy-MM-ddTHH:mm:ssZzzz"
|
f = "yyyy-MM-ddTHH:mm:ssZzzz"
|
||||||
assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
|
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"
|
# RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
|
||||||
s = "2006-01-12T15:04:05.999999999Z-07:00"
|
s = "2006-01-12T15:04:05.999999999Z-07:00"
|
||||||
f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"
|
f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue