'datetime in UTC -> datetime in local time.'

def fromutc(self, dt):

    if (not isinstance(dt, datetime)):
        raise TypeError('fromutc()    requires    a    datetime    argument')
    if (dt.tzinfo is not self):
        raise ValueError('dt.tzinfo    is    not    self')
    timestamp = (((((dt.toordinal() - self.EPOCHORDINAL) * 86400) + (dt.hour * 3600)) + (dt.minute * 60)) + dt.second)
    if (timestamp < self.ut[1]):
        tti = self.ti[0]
        fold = 0
    else:
        idx = bisect.bisect_right(self.ut, timestamp)
        assert (self.ut[(idx - 1)] <= timestamp)
        assert ((idx == len(self.ut)) or (timestamp < self.ut[idx]))
        (tti_prev, tti) = self.ti[(idx - 2):idx]
        shift = (tti_prev[0] - tti[0])
        fold = (shift > timedelta(0, (timestamp - self.ut[(idx - 1)])))
    dt += tti[0]
    if fold:
        return dt.replace(fold=1)
    else:
        return dt
