original_docstring:  Parses an ISO 8601 date or datetime string to a python date or datetime.
          Raises a `ValueError` if a conversion was not possible. The returned
          datetime is always considered time-zone aware and defaulting to the
          given timezone `tzinfo` or UTC Zulu if none was specified.
  
          If the optional module :mod:`dateutil` is installed, it is used in
          preference over the :mod:`dateparse <django.utils.dateparse>` functions.
  
          :param value: the string value to be parsed
          :param tzinfo: an optional tzinfo object that is used when the input
                         string is not timezone aware
          :returns: a :class:`datetime.datetime`
      
docstring: Parses an ISO 8601 date or datetime string to a python date or datetime.
  Raises a `ValueError` if a conversion was not possible. The returned
  datetime is always considered time-zone aware and defaulting to the
  given timezone `tzinfo` or UTC Zulu if none was specified.
  
  If the optional module :mod:`dateutil` is installed, it is used in
  preference over the :mod:`dateparse ` functions.
docstring_tokens: Parses an ISO 8601 date or datetime string to a python date or datetime . Raises a ` ValueError ` if a conversion was not possible . The returned datetime is always considered time - zone aware and defaulting to the given timezone ` tzinfo ` or UTC Zulu if none was specified . If the optional module : mod : ` dateutil ` is installed it is used in preference over the : mod : ` dateparse ` functions .
code: def parse_iso8601(value, tzinfo=None):
      """ Parses an ISO 8601 date or datetime string to a python date or datetime.
          Raises a `ValueError` if a conversion was not possible. The returned
          datetime is always considered time-zone aware and defaulting to the
          given timezone `tzinfo` or UTC Zulu if none was specified.
  
          If the optional module :mod:`dateutil` is installed, it is used in
          preference over the :mod:`dateparse <django.utils.dateparse>` functions.
  
          :param value: the string value to be parsed
          :param tzinfo: an optional tzinfo object that is used when the input
                         string is not timezone aware
          :returns: a :class:`datetime.datetime`
      """
  
      tzinfo = tzinfo or utc
      parsers = (parse,) if HAVE_DATEUTIL else (parse_datetime, parse_date)
      for parser in parsers:
          try:
              temporal = parser(value)
          except Exception as e:
              raise ValueError(
                  "Could not parse '%s' to a temporal value. "
                  "Error was: %s" % (value, e)
              )
          if temporal:
              # convert to datetime if necessary
              if not isinstance(temporal, datetime):
                  temporal = datetime.combine(temporal, datetime.min.time())
  
              # use UTC, if the datetime is not already time-zone aware
              if not is_aware(temporal):
                  temporal = make_aware(temporal, tzinfo)
  
              return temporal
  
      raise ValueError("Could not parse '%s' to a temporal value" % value)
code_tokens: def parse_iso8601 ( value , tzinfo = None ) : tzinfo = tzinfo or utc parsers = ( parse , ) if HAVE_DATEUTIL else ( parse_datetime , parse_date ) for parser in parsers : try : temporal = parser ( value ) except Exception as e : raise ValueError ( "Could not parse '%s' to a temporal value. " "Error was: %s" % ( value , e ) ) if temporal : if not isinstance ( temporal , datetime ) : temporal = datetime . combine ( temporal , datetime . min . time ( ) ) if not is_aware ( temporal ) : temporal = make_aware ( temporal , tzinfo ) return temporal raise ValueError ( "Could not parse '%s' to a temporal value" % value )
short_docstring: Parses an ISO 8601 date or datetime string to a python date or datetime.
short_docstring_tokens: Parses an ISO 8601 date or datetime string to a python date or datetime .
comment: """ Parses an ISO 8601 date or datetime string to a python date or datetime.
          Raises a `ValueError` if a conversion was not possible. The returned
          datetime is always considered time-zone aware and defaulting to the
          given timezone `tzinfo` or UTC Zulu if none was specified.
  
          If the optional module :mod:`dateutil` is installed, it is used in
          preference over the :mod:`dateparse <django.utils.dateparse>` functions.
  
          :param value: the string value to be parsed
          :param tzinfo: an optional tzinfo object that is used when the input
                         string is not timezone aware
          :returns: a :class:`datetime.datetime`
      """$SEP$# convert to datetime if necessary$SEP$# use UTC, if the datetime is not already time-zone aware