How to monitor a switch's state and do X if switch has remained in state B

This should get you on the right path. I think I got all of the conditions but didn't test anything.

#define SWITCH_TIMELIMIT 7200000
#define SWITCH_PIN 2

void loop()
{
  static unsigned long switch_timestamp = 0;
  bool switch_state = digitalRead(SWITCH_PIN);

  if(switch_state && switch_timestamp && (millis() - switch_timestamp) >= SWITCH_TIMELIMIT)
  {
    //Do something important here.

    //if you want to reset the warning:
    //switch_timestamp = 0;
  }
  else if (!switch_timestamp && switch_state)
  {
    //The !switch_timestamp is to make sure we don't refresh the timer if the switch remained on.
    //The pin just changed to on, start the timer
    switch_timestamp = millis();
  }
  else if(!switch_state && switch_timestamp)
  {
    //Switch went off, while timer was running, disable the timer
    switch_timestamp = 0; 
  }

}