piplcom / piplapis-python

Python client library for Pipl's APIs
Other
33 stars 29 forks source link

ValueError: unconverted data remains: T00:00:00 #3

Closed gstub closed 7 years ago

gstub commented 8 years ago

When attempting to use SearchAPIResponse.from_dict, if a date value contains a time it fails. The source of the error is in util.py line 60. I fixed the error by defining:

TIMESTAMP_FORMAT_WITH_TIME = '%Y-%m-%dT%H:%M:%S'

And changing line 60 to read

try:
    return datetime.datetime.strptime(s, TIMESTAMP_FORMAT)
except ValueError:
    return datetime.datetime.strptime(s, TIMESTAMP_FORMAT_WITH_TIME)

Not sure if that's the best solution but I've run into the error multiple times so I figured I'd report it.

uda commented 8 years ago

I believe my PR #7 solved this issue.

the issue wasn't with the formatter, but with checking isinstance date being before datetime, (datetime inherits date).

uda commented 7 years ago

@edoshor or @caligula1989, can you bump up the version and import into pypi to reflect these changes?

joshliberty commented 7 years ago

A new version will go up to pypi in the upcoming 1-2 weeks

joshliberty commented 7 years ago

Fixed in new release: 5.1.1

uda commented 7 years ago

@caligula1989, I know this is closed, but I noticed that the @valid_since is a date, yet in from_dict it is treated as datetime, if you never return a datetime value in @valid_since then this should be changed.