from datetime import datetime


def machine_schedule_active(machine, dt=None):
    """ Return true if the machine is scheduled to be running at a specific time (or now, if not specified)"""
    if not dt:
        dt = datetime.now()
    # Get the shift for this day of the week
    shift = machine.schedule.get_shifts().get(dt.weekday())
    shift_start = datetime.combine(dt, datetime.strptime(shift[0], "%H%M").timetz())
    shift_end = datetime.combine(dt, datetime.strptime(shift[1], "%H%M").timetz())
    if shift_start < dt < shift_end:
        return True
    else:
        return False