from datetime import datetime
from dateutil import tz


def _localized_time(dt):
    """Convert a datetime object to local time"""
    if isinstance(dt, datetime):
        return dt.astimezone(tz.tzlocal())
    else:
        return dt