'Return the time formatted according to ISO.
This is \'YYYY-MM-DD HH:MM:SS.mmmmmm\', or \'YYYY-MM-DD HH:MM:SS\' if
self.microsecond == 0.
If self.tzinfo is not None, the UTC offset is also attached, giving
\'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM\' or \'YYYY-MM-DD HH:MM:SS+HH:MM\'.
Optional argument sep specifies the separator between date and
time, default \'T\'.'

def isoformat(self, sep='T'):

    s = (('%04d-%02d-%02d%c' % (self._year, self._month, self._day, sep)) + _format_time(self._hour, self._minute, self._second, self._microsecond))
    off = self.utcoffset()
    if (off is not None):
        if (off.days < 0):
            sign = '-'
            off = (- off)
        else:
            sign = '+'
        (hh, mm) = divmod(off, timedelta(hours=1))
        assert (not (mm % timedelta(minutes=1))), 'whole    minute'
        mm //= timedelta(minutes=1)
        s += ('%s%02d:%02d' % (sign, hh, mm))
    return s
