def make_date(obj: Union[date, datetime, Text], timezone: tzinfo=None):
    """
    A flexible method to get a date object.

    It accepts either an ISO 8601 date/time string, either a Python `datetime`,
    either a Python `date`.

    If the input is a date/time and a timezone is specified, the resulting
    date object will be in the specified time zone.
    """

    if isinstance(obj, datetime):
        if hasattr(obj, 'astimezone') and timezone:
            obj = obj.astimezone(timezone)
        return obj.date()
    elif isinstance(obj, date):
        return obj
    elif isinstance(obj, str):
        return make_date(parse_date(obj), timezone)
def make_date ( obj : Union [ date , datetime , Text ] , timezone : tzinfo = None ) : if isinstance ( obj , datetime ) : if hasattr ( obj , 'astimezone' ) and timezone : obj = obj . astimezone ( timezone ) return obj . date ( ) elif isinstance ( obj , date ) : return obj elif isinstance ( obj , str ) : return make_date ( parse_date ( obj ) , timezone )
A flexible method to get a date object.

    It accepts either an ISO 8601 date/time string, either a Python `datetime`,
    either a Python `date`.

    If the input is a date/time and a timezone is specified, the resulting
    date object will be in the specified time zone.