Returns a date object parsed from :val:.

  :param val: a string to be parsed as a date
  :param fmt: a format string, a tuple of format strings, or None. If None a
              built in list of format strings will be used to try to parse the
              date.

def parse_date(val, fmt=None):
  """Returns a date object parsed from :val:.

  :param val: a string to be parsed as a date
  :param fmt: a format string, a tuple of format strings, or None. If None a
              built in list of format strings will be used to try to parse the
              date.
  """
  if isinstance(val, date):
    return val
  else:
    return parse_datetime(val, fmt).date()