from datetime import datetime


def str_to_date(date_string, spec="%Y%m%d"):
  """
  Constructs a datetime.date object from string

  Args:
    date_string(str): Date in string (ex: 20130718)
    spec(str): a datetime spec

  Returns:
    date(date)

  Raises:
    TypeError: date_string or spec is not a str
    ValueError: date_string is not a valid date
  """
  return datetime.strptime(date_string, spec).date()