code: def parse(text):
          
          try:
              ymd = text.lower().split('-')
              assert len(ymd) == 3
              year = -1 if ymd[0] in ('xx', 'xxxx') else int(ymd[0])
              month = -1 if ymd[1] == 'xx' else int(ymd[1])
              day = -1 if ymd[2] == 'xx' else int(ymd[2])
              assert not year == month == day == -1
              assert month == -1 or 1 <= month <= 12
              assert day == -1 or 1 <= day <= 31
              return (year, month, day)
          except (ValueError, AssertionError):
              return None
docs: Try to parse into a date.
  
          Return:
              tuple (year, month, date) if successful; otherwise None.