code: def filter_pastdate(string, default=None):
      if not string and default is not None:
          return default
      today = datetime.date.today()
      try:
          parts = map(int, re.split('\D+', string))
      except ValueError:
          raise InvalidInputError("invalid date; use format: DD [MM [YYYY]]")
      if len(parts) < 1 or len(parts) > 3:
          raise InvalidInputError("invalid date; use format: DD [MM [YYYY]]")
      if len(parts) == 1:
          parts.append(today.month - 1 if parts[0] > today.day else today.month)
          if parts[1] < 1:
              parts[1] = 12
      if len(parts) == 2:
          if parts[1] > today.month \
            or parts[1] == today.month and parts[0] > today.day:
              parts.append(today.year - 1)
          else:
              parts.append(today.year)
      parts.reverse()
      try:
          date = datetime.date(*parts)
          if date > today:
              raise InvalidInputError("cannot choose a date in the future")
          return date
      except ValueError:
          print parts
          raise InvalidInputError("invalid date; use format: DD [MM [YYYY]]")