Programming limit switch?

It should be marking time, that is to say waiting for one hour to pass.

This is easy enough to do easily and would also be fun to take a bit more sophisticated approach.

loop
   trundle left until the left limit switch is hit

   do nothing for one hour

   trundle right until the right limit switch is hit

   do nothing for one hour

You've said the motor turns one way only, so it's even simpler

loop
   trundle until either limit switch is hit
   do nothing for one hour

The key is being able to see when the switch becomes pressed, not when it is being pressed.

This is a basic concept it will be worth getting your head around. It is referred to as "edge detection" or "state change detection". There is a demonstration of this in the IDE examlkes and it links to a competent article on the subject.

Fortunately there are also several many other people who have covered the same idea. Multiple perspectives can be helpful; one explanation may land better than another for you.

https://docs.arduino.cc/built-in-examples/digital/StateChangeDetection/

Of course we all feel like we've explained it once and perfectly:

HTH - start turning on and off some LEDs using pushbuttons.

a7