Closed walchko closed 6 years ago
The problem is that .timetuple()
only works with second-level precision. To keep the microsecond precision, use .timestamp()
.
>>> s = '2011-09-28 12:26:18.089952593'
>>> t = datetime.datetime.strptime(s[:-4], "%Y-%m-%d %I:%M:%S.%f")
>>> t
datetime.datetime(2011, 9, 28, 0, 26, 18, 89950)
>>> t.timetuple()
time.struct_time(tm_year=2011, tm_mon=9, tm_mday=28, tm_hour=0, tm_min=26, tm_sec=18, tm_wday=2, tm_yday=271, tm_isdst=-1)
>>> time.mktime(t.timetuple())
1317183978.0
>>> t.timestamp()
1317183978.08995
I don't think you are parsing the raw time stamps correctly in raw.py. When I try to do this in python 3.7 on macOS, I get the same as when I ignore the fractional seconds:
They are the same!
However, if I just turn the fractional part into a float and add it, I get (I think) the correct answer:
Looking at the time stamp, I think (with this fractional part) is correct.