def convert_to_local_time(dt): if dt.tzinfo: return dt.astimezone(LOCAL_TIMEZONE) else: return dt.replace(tzinfo=UTC_TIMEZONE).astimezone(LOCAL_TIMEZONE)