# Buggy code
def from_proto(cls, proto: qtypes.QuantumTimeSlot):
    slot_type = qenums.QuantumTimeSlot.TimeSlotType(proto.slot_type)
    if proto.HasField("reservation_config"):
        return cls(
            processor_id=proto.processor_name,
            start_time=datetime.datetime.fromtimestamp(proto.start_time.seconds),
            end_time=datetime.datetime.fromtimestamp(proto.end_time.seconds),
            slot_type=slot_type,
            project_id=proto.reservation_config.project_id,
        )
    if proto.HasField("maintenance_config"):
        return cls(
            processor_id=proto.processor_name,
            start_time=datetime.datetime.fromtimestamp(proto.start_time.seconds),
            end_time=datetime.datetime.fromtimestamp(proto.end_time.seconds),
            slot_type=slot_type,
            maintenance_title=proto.maintenance_config.title,
            maintenance_description=proto.maintenance_config.description,
        )
    return cls(
        processor_id=proto.processor_name,
        start_time=datetime.datetime.fromtimestamp(proto.start_time.seconds),
        end_time=datetime.datetime.fromtimestamp(proto.end_time.seconds),
        slot_type=slot_type,
    )


# Traceback (ValueError)
Traceback (most recent call last):
File "/home/lingyihu/miniconda3/envs/recirq/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/lingyihu/miniconda3/envs/recirq/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/lingyihu/projects/ReCirq/recirq/quantum_chess/experiments/batch_moves.py", line 94, in <module>
main_loop(parse())
File "/home/lingyihu/projects/ReCirq/recirq/quantum_chess/experiments/batch_moves.py", line 60, in main_loop
available_processors = utils.get_available_processors(utils.QUANTUM_PROCESSORS.keys())
File "/home/lingyihu/projects/ReCirq/recirq/engine_utils.py", line 405, in get_available_processors
time_slot = EngineTimeSlot.from_proto(time_slot)
File "/home/lingyihu/miniconda3/envs/recirq/lib/python3.9/site-packages/cirq/google/engine/engine_timeslot.py", line 75, in from_proto
end_time=datetime.datetime.fromtimestamp(
ValueError: year 0 is out of range

# Fixed code
def from_proto(cls, proto: qtypes.QuantumTimeSlot):
    slot_type = qenums.QuantumTimeSlot.TimeSlotType(proto.slot_type)
    start_time = None
    end_time = None
    if proto.HasField("start_time"):
        start_time = datetime.datetime.fromtimestamp(proto.start_time.seconds)
    if proto.HasField("end_time"):
        end_time = datetime.datetime.fromtimestamp(proto.end_time.seconds)
    if proto.HasField("reservation_config"):
        return cls(
            processor_id=proto.processor_name,
            start_time=start_time,
            end_time=end_time,
            slot_type=slot_type,
            project_id=proto.reservation_config.project_id,
        )
    if proto.HasField("maintenance_config"):
        return cls(
            processor_id=proto.processor_name,
            start_time=start_time,
            end_time=end_time,
            slot_type=slot_type,
            maintenance_title=proto.maintenance_config.title,
            maintenance_description=proto.maintenance_config.description,
        )
    return cls(
        processor_id=proto.processor_name,
        start_time=start_time,
        end_time=end_time,
        slot_type=slot_type,
    )