(dt)
return dt.strftime(ISO_DATETIME_FORMAT)
includes microseconds (always)
    >>> json_format_datetime(datetime.datetime(2015, 4, 8, 12, 0, 1))
    '2015-04-08T12:00:01.000000Z'
includes microseconds (always)
    >>> json_format_datetime(datetime.datetime(2015, 4, 8, 12, 0, 1))
    '2015-04-08T12:00:01.000000Z'
includes microseconds ( always ) >>> json_format_datetime ( datetime . datetime ( 2015 4 8 12 0 1 )) 2015 - 04 - 08T12 : 00 : 01 . 000000Z
def json_format_datetime(dt):
    """
    includes microseconds (always)
    >>> json_format_datetime(datetime.datetime(2015, 4, 8, 12, 0, 1))
    '2015-04-08T12:00:01.000000Z'
    """
    from dimagi.ext.jsonobject import _assert
    _assert(isinstance(dt, datetime),
            'json_format_datetime expects a datetime: {!r}'.format(dt))
    if isinstance(dt, datetime):
        _assert(dt.tzinfo is None,
                'json_format_datetime expects offset-naive: {!r}'.format(dt))
    return dt.strftime(ISO_DATETIME_FORMAT)
def json_format_datetime ( dt ) : from dimagi . ext . jsonobject import _assert _assert ( isinstance ( dt , datetime ) , 'json_format_datetime expects a datetime: {!r}' . format ( dt ) ) if isinstance ( dt , datetime ) : _assert ( dt . tzinfo is None , 'json_format_datetime expects offset-naive: {!r}' . format ( dt ) ) return dt . strftime ( ISO_DATETIME_FORMAT )