original_docstring: 
          Converts the given text to a date value.
          
docstring: Converts the given text to a date value.
docstring_tokens: Converts the given text to a date value .
code: def parse_date(text):
          """
          Converts the given text to a date value.
          """
  
          # Check the text has a value:
          if text is None:
              return None
  
          # Extract the time zone:
          tz = None
          if text[-1] == 'Z':
              tz = TZ(0, 'UTC')
              text = text[:-1]
          else:
              match = TZ_OFFSET_RE.search(text)
              if match:
                  name = match.group(0)
                  sign = match.group('sign')
                  hours = int(match.group('hours'))
                  minutes = int(match.group('minutes'))
                  offset = hours * 60 + minutes
                  if sign == '-':
                      offset *= -1
                  tz = TZ(offset, name)
                  text = text[:-len(name)]
  
          # Parse the rest of the date:
          format = '%Y-%m-%dT%H:%M:%S'
          if TZ_USEC_RE.search(text):
              format += '.%f'
          try:
              try:
                  date = datetime.datetime.strptime(text, format)
              except TypeError:
                  # when have TypeError: attribute of type 'NoneType'
                  #  workaround to treat a issue of python module: https://bugs.python.org/issue27400
                  date = datetime.datetime.fromtimestamp(time.mktime(time.strptime(text, format)))
          except ValueError:
              raise ValueError(
                  'The text \'%s\' isn\'t a valid date value' % text
              )
  
          # Set the time zone:
          if tz is not None:
              date = date.replace(tzinfo=tz)
  
          return date
code_tokens: def parse_date ( text ) : if text is None : return None tz = None if text [ - 1 ] == 'Z' : tz = TZ ( 0 , 'UTC' ) text = text [ : - 1 ] else : match = TZ_OFFSET_RE . search ( text ) if match : name = match . group ( 0 ) sign = match . group ( 'sign' ) hours = int ( match . group ( 'hours' ) ) minutes = int ( match . group ( 'minutes' ) ) offset = hours * 60 + minutes if sign == '-' : offset *= - 1 tz = TZ ( offset , name ) text = text [ : - len ( name ) ] format = '%Y-%m-%dT%H:%M:%S' if TZ_USEC_RE . search ( text ) : format += '.%f' try : try : date = datetime . datetime . strptime ( text , format ) except TypeError : date = datetime . datetime . fromtimestamp ( time . mktime ( time . strptime ( text , format ) ) ) except ValueError : raise ValueError ( 'The text \'%s\' isn\'t a valid date value' % text ) if tz is not None : date = date . replace ( tzinfo = tz ) return date
short_docstring: Converts the given text to a date value.
short_docstring_tokens: Converts the given text to a date value .
comment: """
          Converts the given text to a date value.
          """$SEP$# Check the text has a value:$SEP$# Extract the time zone:$SEP$# Parse the rest of the date:$SEP$# when have TypeError: attribute of type 'NoneType'$SEP$#  workaround to treat a issue of python module: https://bugs.python.org/issue27400$SEP$# Set the time zone: