def convert_timezone ( obj , timezone ) : if timezone is None : return obj . replace ( tzinfo = None ) return pytz . timezone ( timezone ) . localize ( obj )
timezone with z in python
Convert obj to the timezone timezone .
def convert_timezone(obj, timezone):
    """Convert `obj` to the timezone `timezone`.

    Parameters
    ----------
    obj : datetime.date or datetime.datetime

    Returns
    -------
    type(obj)
    """
    if timezone is None:
        return obj.replace(tzinfo=None)
    return pytz.timezone(timezone).localize(obj)