Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #52989: DateTime parser would return an error when parsing a year string #53954

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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