Closed jaridmargolin closed 4 years ago
By way of example, notice the milliseconds in the original (057350) and the converted (573500)
'original': '2020-03-25T19:34:05.057350Z
'converted': datetime.datetime(2020, 3, 25, 19, 34, 5, 573500)
This was the only discussion I could find even remotely about this problem: python: subtraction of timestamps fails due to omitted leading zeros in microsec
And it lead me to the discovery that the timedelta class has a milliseconds argument I could use, which allowed me to break up the microseconds into two chunks of 3 and then add them to the timestamp to keep the correct value from the parsed string datetime.
search:
int(...)
is used several times within the convert method ofTimestampType
. This, however, leads to the unintended consequence of trimming off leading 0s from any string segment. All usages ofint(...)
should be replaced with alternative solutions.