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: datetime tryparse (#265) #267

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
19 changes: 16 additions & 3 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,23 @@ function pqparse(::Type{DateTime}, str::AbstractString)
parsed = _tryparse_datetime_inf(DateTime, str)
isnothing(parsed) || return parsed

parsed = tryparse(DateTime, str, TIMESTAMP_FORMAT)
isnothing(parsed) || return parsed
# Please, do not remove @static, see https://github.com/iamed2/LibPQ.jl/issues/265
# for more details
@static if v"1.6.6" <= VERSION < v"1.7.0" || VERSION > v"1.7.2"
iamed2 marked this conversation as resolved.
Show resolved Hide resolved
parsed = tryparse(DateTime, str, TIMESTAMP_FORMAT)
isnothing(parsed) || return parsed

return parse(DateTime, _trunc_seconds(str), TIMESTAMP_FORMAT)
return parse(DateTime, _trunc_seconds(str), TIMESTAMP_FORMAT)
else
try
return parse(DateTime, str, TIMESTAMP_FORMAT)
catch err
if !(err isa InexactError)
rethrow(err)
end
end
return parse(DateTime, _trunc_seconds(str), TIMESTAMP_FORMAT)
end
end

# ISO, YMD
Expand Down