from datetime import datetime


def local_to_utc(dtime, zoneinfo=None):
    """Convert local time to  UTC time"""
    if dtime.tzinfo is not None:
        return dtime - dtime.utcoffset()
    year, month, day = dtime.year, dtime.month, dtime.day
    hour, minute = dtime.hour, dtime.minute
    return datetime(year, month, day, hour, minute, tzinfo=zoneinfo)