Skip to content

Commit

Permalink
switch to version based logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Wynand committed May 9, 2022
1 parent 4f774dc commit 565265d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,23 @@ end

_DEFAULT_TYPE_MAP[:time] = Time
function pqparse(::Type{Time}, str::AbstractString)
result = nothing
try
@static if v"1.6.6" <= VERSION < v"1.7.0" || VERSION >= "1.7.2"
result = tryparse(Time, str)
catch err
if !(err isa InexactError)
rethrow(err)
if isnothing(result)
# If there's an error we want to see it here
result = parse(Time, _trunc_seconds(str))
end
return result
else
try
return parse(Time, str)
catch err
if !(err isa InexactError)
rethrow(err)
end
return parse(Time, _trunc_seconds(str))
end
end
return isnothing(result) ? parse(Time, _trunc_seconds(str)) : result
end

# InfExtendedTime support for Dates.TimeType
Expand Down

0 comments on commit 565265d

Please sign in to comment.