def to_iso_format(
        date_time):
    """
    Return a string representing the date and time in ISO 8601 format,
    YYYY-MM-DD HH:MM:SS.mmmmmm or, if microsecond is 0, YYYY-MM-DD HH:MM:SS

    If utcoffset() does not return None, a 6-character string is appended,
    giving the UTC offset in (signed) hours and minutes:
    YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM or, if microsecond is 0
    YYYY-MM-DD HH:MM:SS+HH:MM
    """
    return date_time.isoformat(sep=" ")