You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current python implementation fails to convert the returned ISO-formatted timestamp to a datetime object if the characters representing seconds are less than 10.
For example, I have seen both 2014-08-15T15:39:55.461264+03:00 and 2014-08-15T15:39:55.5706103+03:00 returned by the REST API as TimeStamp in actual calls.
In the former case the parser fails since it tries to convert 55.461264+ to float.
The obvious solution is to replace L83: time_tokens = timestamp[11:27].split(':') with L83: time_tokens = timestamp[11:26].split(':') so that only the first 9 digits of seconds are parsed (or maybe even less).
However, I strongly recommend using a library such as dateutil to do this kind of work. It will add a dependency, but a pretty common one. Dateutil will also add timezone information, which is currently missing.
As a side note, I'd like to see other datetime objects returned by the REST API (such as InsDate returned by get_transaction) converted too, currently the wrapper only deals with TimeStamp.
If needed, I could create a pull request for this issue.
The text was updated successfully, but these errors were encountered:
ppetrid
pushed a commit
to ppetrid/API
that referenced
this issue
Aug 17, 2014
Added 'InsDate' & 'ClearanceDate` to the parsed datetimes, used the dateutil module for reliable conversion. Added minor PEP8 fixes (identation & line length)
The current python implementation fails to convert the returned ISO-formatted timestamp to a datetime object if the characters representing seconds are less than 10.
For example, I have seen both
2014-08-15T15:39:55.461264+03:00
and2014-08-15T15:39:55.5706103+03:00
returned by the REST API asTimeStamp
in actual calls.In the former case the parser fails since it tries to convert
55.461264+
to float.The obvious solution is to replace
L83:
time_tokens = timestamp[11:27].split(':')
withL83:
time_tokens = timestamp[11:26].split(':')
so that only the first 9 digits of seconds are parsed (or maybe even less).However, I strongly recommend using a library such as dateutil to do this kind of work. It will add a dependency, but a pretty common one. Dateutil will also add timezone information, which is currently missing.
As a side note, I'd like to see other datetime objects returned by the REST API (such as
InsDate
returned by get_transaction) converted too, currently the wrapper only deals withTimeStamp
.If needed, I could create a pull request for this issue.
The text was updated successfully, but these errors were encountered: