import time, datetime

def utcfromtimestamp(t):
    t, frac = divmod(t, 1.0)
us = int(frac * 1000000.0)
if us == 1000000:
    t += 1
us = 0
y, m, d, hh, mm, ss, weekday, jday, dst = time.gmtime(t)
ss = min(ss, 59)
return datetime.datetime(y, m, d, hh, mm, ss, us)
Странное поведение округления даты и времени между python 2 и 3