def _convert_listlike_datetimes(arg, box, format, name=None, tz=None,<EOL>unit=None, errors=None,<EOL>infer_datetime_format=None, dayfirst=None,<EOL>yearfirst=None, exact=None):
from pandas import DatetimeIndex<EOL>from pandas.core.arrays import DatetimeArray<EOL>from pandas.core.arrays.datetimes import (<EOL>maybe_convert_dtype, objects_to_datetime64ns)<EOL>if isinstance(arg, (list, tuple)):<EOL><INDENT>arg = np.array(arg, dtype='<STR_LIT:O>')<EOL><DEDENT>if is_datetime64tz_dtype(arg):<EOL><INDENT>if not isinstance(arg, (DatetimeArray, DatetimeIndex)):<EOL><INDENT>return DatetimeIndex(arg, tz=tz, name=name)<EOL><DEDENT>if tz == '<STR_LIT>':<EOL><INDENT>arg = arg.tz_convert(None).tz_localize(tz)<EOL><DEDENT>return arg<EOL><DEDENT>elif is_datetime64_ns_dtype(arg):<EOL><INDENT>if box and not isinstance(arg, (DatetimeArray, DatetimeIndex)):<EOL><INDENT>try:<EOL><INDENT>return DatetimeIndex(arg, tz=tz, name=name)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return arg<EOL><DEDENT>elif unit is not None:<EOL><INDENT>if format is not None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>arg = getattr(arg, '<STR_LIT>', arg)<EOL>result = tslib.array_with_unit_to_datetime(arg, unit,<EOL>errors=errors)<EOL>if box:<EOL><INDENT>if errors == '<STR_LIT:ignore>':<EOL><INDENT>from pandas import Index<EOL>result = Index(result, name=name)<EOL>try:<EOL><INDENT>return result.tz_localize(tz)<EOL><DEDENT>except AttributeError:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>return DatetimeIndex(result, tz=tz, name=name)<EOL><DEDENT>return result<EOL><DEDENT>elif getattr(arg, '<STR_LIT>', <NUM_LIT:1>) > <NUM_LIT:1>:<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>orig_arg = arg<EOL>arg, _ = maybe_convert_dtype(arg, copy=False)<EOL>arg = ensure_object(arg)<EOL>require_iso8601 = False<EOL>if infer_datetime_format and format is None:<EOL><INDENT>format = _guess_datetime_format_for_array(arg, dayfirst=dayfirst)<EOL><DEDENT>if format is not None:<EOL><INDENT>format_is_iso8601 = _format_is_iso(format)<EOL>if format_is_iso8601:<EOL><INDENT>require_iso8601 = not infer_datetime_format<EOL>format = None<EOL><DEDENT><DEDENT>tz_parsed = None<EOL>result = None<EOL>if format is not None:<EOL><INDENT>try:<EOL><INDENT>if format == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>orig_arg = ensure_object(orig_arg)<EOL>result = _attempt_YYYYMMDD(orig_arg, errors=errors)<EOL><DEDENT>except (ValueError, TypeError, tslibs.OutOfBoundsDatetime):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if result is None:<EOL><INDENT>try:<EOL><INDENT>result, timezones = array_strptime(<EOL>arg, format, exact=exact, errors=errors)<EOL>if '<STR_LIT>' in format or '<STR_LIT>' in format:<EOL><INDENT>return _return_parsed_timezone_results(<EOL>result, timezones, box, tz, name)<EOL><DEDENT><DEDENT>except tslibs.OutOfBoundsDatetime:<EOL><INDENT>if errors == '<STR_LIT>':<EOL><INDENT>raise<EOL><DEDENT>elif errors == '<STR_LIT>':<EOL><INDENT>result = np.empty(arg.shape, dtype='<STR_LIT>')<EOL>iresult = result.view('<STR_LIT>')<EOL>iresult.fill(tslibs.iNaT)<EOL><DEDENT>else:<EOL><INDENT>result = arg<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>if not infer_datetime_format:<EOL><INDENT>if errors == '<STR_LIT>':<EOL><INDENT>raise<EOL><DEDENT>elif errors == '<STR_LIT>':<EOL><INDENT>result = np.empty(arg.shape, dtype='<STR_LIT>')<EOL>iresult = result.view('<STR_LIT>')<EOL>iresult.fill(tslibs.iNaT)<EOL><DEDENT>else:<EOL><INDENT>result = arg<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>except ValueError as e:<EOL><INDENT>try:<EOL><INDENT>values, tz = conversion.datetime_to_datetime64(arg)<EOL>return DatetimeIndex._simple_new(values, name=name, tz=tz)<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>raise e<EOL><DEDENT><DEDENT><DEDENT>if result is None:<EOL><INDENT>assert format is None or infer_datetime_format<EOL>utc = tz == '<STR_LIT>'<EOL>result, tz_parsed = objects_to_datetime64ns(<EOL>arg, dayfirst=dayfirst, yearfirst=yearfirst,<EOL>utc=utc, errors=errors, require_iso8601=require_iso8601,<EOL>allow_object=True)<EOL><DEDENT>if tz_parsed is not None:<EOL><INDENT>if box:<EOL><INDENT>return DatetimeIndex._simple_new(result, name=name,<EOL>tz=tz_parsed)<EOL><DEDENT>else:<EOL><INDENT>result = [Timestamp(ts, tz=tz_parsed).to_pydatetime()<EOL>for ts in result]<EOL>return np.array(result, dtype=object)<EOL><DEDENT><DEDENT>if box:<EOL><INDENT>if is_datetime64_dtype(result):<EOL><INDENT>return DatetimeIndex(result, tz=tz, name=name)<EOL><DEDENT>elif is_object_dtype(result):<EOL><INDENT>from pandas import Index<EOL>return Index(result, name=name)<EOL><DEDENT><DEDENT>return result<EOL>
Helper function for to_datetime. Performs the conversions of 1D listlike
of dates

Parameters
----------
arg : list, tuple, ndarray, Series, Index
    date to be parced
box : boolean
    True boxes result as an Index-like, False returns an ndarray
name : object
    None or string for the Index name
tz : object
    None or 'utc'
unit : string
    None or string of the frequency of the passed data
errors : string
    error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
infer_datetime_format : boolean
    inferring format behavior from to_datetime
dayfirst : boolean
    dayfirst parsing behavior from to_datetime
yearfirst : boolean
    yearfirst parsing behavior from to_datetime
exact : boolean
    exact format matching behavior from to_datetime

Returns
-------
ndarray of parsed dates
    Returns:

    - Index-like if box=True
    - ndarray of Timestamps if box=False