def to_date(value):
    """转化为 datetime.date 类型"""
    if not value:
        return value
    if isinstance(value, six.string_types):
        date = value[:10]
        try:
            separator = date[4]
            if separator in {'-', '/'}:
                return datetime.date(*map(int, date.split(separator)))
            else:
                return datetime.date(int(value[:4]), int(value[4:6]), int(value[6:8]))
        except Exception:
            pass
    elif isinstance(value, datetime.datetime):
        return value.date()
    elif isinstance(value, datetime.date):
        return value
    elif isinstance(value, int):
        return to_date(str(value))
    elif isinstance(value, bytes):
        return to_date(value.decode('utf8'))
    raise ValueError("无效的日期：{!r}".format(value))
转化为 datetime.date 类型
jqdatasdk/utils.py