'Serialize a C{datetime.datetime} instance to a string in the specified
wire format.'

def toString(self, i):

    offset = i.utcoffset()
    if (offset is None):
        raise ValueError('amp.DateTime    cannot    serialize    naive    datetime    instances.        You    may    find    amp.utc    useful.')
    minutesOffset = (((offset.days * 86400) + offset.seconds) // 60)
    if (minutesOffset > 0):
        sign = '+'
    else:
        sign = '-'
    packed = (u'%04i-%02i-%02iT%02i:%02i:%02i.%06i%s%02i:%02i' % (i.year, i.month, i.day, i.hour, i.minute, i.second, i.microsecond, sign, (abs(minutesOffset) // 60), (abs(minutesOffset) % 60)))
    return packed.encode('ascii')
