def format_iso_datetime(datetime_obj):
    """Formats the given datetime as a UTC-zoned ISO 8601 date string.

    :param datetime_obj: The datetime object.
    :type datetime_obj: datetime
    :return: The datetime object in 8601 string form.
    :rtype: datetime
    """
    datetime_obj = localize_datetime(datetime_obj, pytz.utc)
    if datetime_obj < MIN_DATE:
        datetime_obj = MIN_DATE
    elif datetime_obj > MAX_DATE:
        datetime_obj = MAX_DATE
    return datetime_obj.replace(tzinfo=None).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
def format_iso_datetime ( datetime_obj ) : datetime_obj = localize_datetime ( datetime_obj , pytz . utc ) if datetime_obj < MIN_DATE : datetime_obj = MIN_DATE elif datetime_obj > MAX_DATE : datetime_obj = MAX_DATE return datetime_obj . replace ( tzinfo = None ) . strftime ( '%Y-%m-%dT%H:%M:%S.%f' ) [ : - 3 ] + 'Z'
Formats the given datetime as a UTC-zoned ISO 8601 date string.

    :param datetime_obj: The datetime object.
    :type datetime_obj: datetime
    :return: The datetime object in 8601 string form.
    :rtype: datetime