Skip to content

Commit

Permalink
Fix JuliaLang#52989: DateTime parser would return an error when parsi…
Browse files Browse the repository at this point in the history
…ng a year string
  • Loading branch information
Viriato5 committed Mar 28, 2024
1 parent 6f51966 commit 4d35ea1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/Dates/src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function Base.parse(::Type{DateTime}, s::AbstractString, df::typeof(ISODateTimeF
let val = tryparsenext_base10(s, i, end_pos, 1)
val === nothing && @goto error
dy, i = val
i > end_pos && @goto error
i > end_pos && @goto done
end

c, i = iterate(s, i)::Tuple{Char, Int}
Expand Down
3 changes: 3 additions & 0 deletions stdlib/Dates/test/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ end
# Issue #44003
@test tryparse(Dates.Date, "2017", Dates.DateFormat(".s")) === nothing

# Issue #52989
@test Dates.DateTime("2000") == Dates.DateTime(2000)

@testset "parse milliseconds, Issue #22100" begin
@test Dates.DateTime("2017-Mar-17 00:00:00.0000", "y-u-d H:M:S.s") == Dates.DateTime(2017, 3, 17)
@test Dates.parse_components(".1", Dates.DateFormat(".s")) == [Dates.Millisecond(100)]
Expand Down

0 comments on commit 4d35ea1

Please sign in to comment.