from datetime import datetime


def datestr2date(x, date_format='%Y-%m-%d'):
    """
        convert date string to date object

        Parameters
        ----------
        x: string or datetime object

        Returns
        -------
        datetime object
    """

    if isinstance(x, list):
        return [datetime.strptime(item, date_format).date() for item in x]
    else:
        return datetime.strptime(x, date_format).date()