I have times in a log that look like this:
1440498131.372625
What I've done using pytz is
utc = pytz.utc
for anra in raFromMCCS:
fsecs = float(anra.time)
isecs = int(fsecs)
isec2 = int(fsecs * 1000)
dt = datetime.utcfromtimestamp(isecs).replace(tzinfo=utc)
#print (dt.year)
dt2 = utc.localize(datetime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, int((fsecs - isecs) * 1000000)))
# dt3 = datetime.utcfromtimestamp(isec2)
print(dt, dt2)#, dt3)
I left in the stupid dt3 attempt to show I'm new to all sorts of things here.
I know that dt2 gives me what I want but it seems like a roundabout way to get there. If you have a nicer solution, please let me know.
Thanks!