code: def relative_date_to_date(p_date, p_offset=None):
      
      result = None
      p_date = p_date.lower()
      p_offset = p_offset or date.today()
  
      relative = re.match('(?P<length>-?[0-9]+)(?P<period>[dwmyb])$',
                          p_date, re.I)
  
      monday = 'mo(n(day)?)?$'
      tuesday = 'tu(e(sday)?)?$'
      wednesday = 'we(d(nesday)?)?$'
      thursday = 'th(u(rsday)?)?$'
      friday = 'fr(i(day)?)?$'
      saturday = 'sa(t(urday)?)?$'
      sunday = 'su(n(day)?)?$'
  
      weekday = re.match('|'.join(
          [monday, tuesday, wednesday, thursday, friday, saturday, sunday]),
          p_date)
  
      if relative:
          length = relative.group('length')
          period = relative.group('period')
          result = _convert_pattern(length, period, p_offset)
  
      elif weekday:
          result = _convert_weekday_pattern(weekday.group(0))
  
      elif re.match('tod(ay)?$', p_date):
          result = _convert_pattern('0', 'd')
  
      elif re.match('tom(orrow)?$', p_date):
          result = _convert_pattern('1', 'd')
  
      elif re.match('yes(terday)?$', p_date):
          result = _convert_pattern('-1', 'd')
  
      return result
docs: Transforms a relative date into a date object.
  
      The following formats are understood:
  
      * [0-9][dwmy]
      * 'yesterday', 'today' or 'tomorrow'
      * days of the week (in full or abbreviated)