def __to_localdatetime ( val ) : try : dt = datetime . strptime ( val , __DATE_FORMAT ) dt = pytz . timezone ( __TIMEZONE ) . localize ( dt ) return dt except ( ValueError , TypeError ) : return None
cast a variable to tz in python
Convert val into a local datetime for tz Europe / Amsterdam .
def __to_localdatetime(val):
    """Convert val into a local datetime for tz Europe/Amsterdam."""
    try:
        dt = datetime.strptime(val, __DATE_FORMAT)
        dt = pytz.timezone(__TIMEZONE).localize(dt)
        return dt
    except (ValueError, TypeError):
        return None