Skip to content

Commit

Permalink
Improve parsing heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Jan 31, 2025
1 parent 68a90ec commit 3e4ead3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ begin
end

function Base.parse(::Type{ZonedDateTime}, str::AbstractString)
res = tryparse(ZonedDateTime, str, ISOZonedDateTimeFormat)
return isnothing(res) ? parse(ZonedDateTime, str, ISOZonedDateTimeNoMillisecondFormat) : res
# Works as the format should only contain a period when milliseconds are included
return if contains(str, '.')
parse(ZonedDateTime, str, ISOZonedDateTimeFormat)
else
parse(ZonedDateTime, str, ISOZonedDateTimeNoMillisecondFormat)
end
end

function Base.parse(::Type{ZonedDateTime}, str::AbstractString, df::DateFormat)
Expand Down

0 comments on commit 3e4ead3

Please sign in to comment.