Skip to content

Commit e1090b1

Browse files
authored
Merge pull request #77 from davidanthoff/fix-date-parsing
Fix date parsing
2 parents 73da796 + 68aa0cc commit e1090b1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/lib/date-tryparse-internal.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,21 @@ Returns a 3-element tuple `(values, pos, num_parsed)`:
107107
vi += 1
108108
quote
109109
pos > len && @goto done
110-
$nullable, next_pos = tryparsenext(directives[$i], str, pos, len, locale)
111-
isnull($nullable) && @goto error
112-
$name = unsafe_get($nullable)
110+
nothingable_tuple = tryparsenext(directives[$i], str, pos, len, locale)
111+
nothingable_tuple===nothing && @goto error
112+
$name = nothingable_tuple[1]
113+
next_pos = nothingable_tuple[2]
113114
pos = next_pos
114115
num_parsed += 1
115116
directive_index += 1
116117
end
117118
else
118119
quote
119120
pos > len && @goto done
120-
nullable_delim, next_pos = tryparsenext(directives[$i], str, pos, len, locale)
121-
isnull(nullable_delim) && @goto error
121+
nothingable_tuple = tryparsenext(directives[$i], str, pos, len, locale)
122+
nothingable_tuple===nothing && @goto error
123+
nullable_delim = nothingable_tuple[1]
124+
next_pos = nothingable_tuple[2]
122125
pos = next_pos
123126
directive_index += 1
124127
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ end
373373
str = "1970-02-02 02:20:20"
374374
@test tryparsenext(tok, str, 1, length(str), opts) |> unwrap == (DateTime("1970-02-02T02:20:20"), length(str)+1)
375375
@test tryparsenext(tok, str*"x", 1, length(str)+1, opts) |> unwrap == (DateTime("1970-02-02T02:20:20"), length(str)+1)
376-
#@test tryparsenext(tok, str[1:end-3]*"x", 1, length(str)-2, opts) |> failedat == length(str)-2
377-
#@test tryparsenext(tok, str[1:end-3]*"y", 1, length(str)-2, opts) |> unwrap == (DateTime("1970-02-02T02:20"), length(str)-2)
376+
@test tryparsenext(tok, str[1:end-3]*"x", 1, length(str)-2, opts) |> failedat == length(str)-2
377+
@test tryparsenext(tok, str[1:end-3]*"y", 1, length(str)-2, opts) |> unwrap == (DateTime("1970-02-02T02:20"), length(str)-2)
378378
end
379379

380380

0 commit comments

Comments
 (0)