code: def parse_date(value):
      
      # Do the regex magic; also enforces 2 or 4 digit years
      match = Definitions.DATE_RE.match(value) if value else None
      if not match:
          return None
      # We're going to extract and prepare captured data in 'data'.
      data = {}
      captured = match.groupdict()
      fields = ['year', 'month', 'day', 'hour', 'minute', 'second']
      # If we matched on the RFC 1123 family format
      if captured['year']:
          for field in fields:
              data[field] = captured[field]
      # If we matched on the asctime format, use year2 etc.
      else:
          for field in fields:
              data[field] = captured[field + "2"]
      year = data['year']
      # Interpret lame 2-digit years - base the cutoff on UNIX epoch, in case
      # someone sets a '70' cookie meaning 'distant past'. This won't break for
      # 58 years and people who use 2-digit years are asking for it anyway.
      if len(year) == 2:
          if int(year) < 70:
              year = "20" + year
          else:
              year = "19" + year
      year = int(year)
      # Clamp to [1900, 9999]: strftime has min 1900, datetime has max 9999
      data['year'] = max(1900, min(year, 9999))
      # Other things which are numbers should convert to integer
      for field in ['day', 'hour', 'minute', 'second']:
          if data[field] is None:
              data[field] = 0
          data[field] = int(data[field])
      # Look up the number datetime needs for the named month
      data['month'] = Definitions.month_numbers[data['month'].lower()]
      return datetime.datetime(**data)
docs: Parse an RFC 1123 or asctime-like format date string to produce
      a Python datetime object (without a timezone).