Creating a blinking "clock" like display that increments at the push of a button

You've all set a clock before, you put it into set time mode and the number you're trying to set blinks. If you click the button, it increments by one. This is what I'm trying to do on an arduino, but I'm trying to implement it all with one button. Ideally you hold it down for a couple seconds to enter time set mode, that I have figured out. However I am completely lost as to go from there and after playing around for a few hours I'm no closer. I would like clicking the button once to increment the hour by one, and if you hold it down for 2-3 seconds it switches to setting the minute. Holding it down for another 2-3 seconds will set it as the correct time in the clock and exit the function. I'm not sure how difficult this is to do with one button, but I'm finding it a huge struggle.

This is the code I have so far after the device enters "time set mode"

void setTime() {
  rtc.update();
  int oldHour = rtc.hour();
  int oldMinute = rtc.minute();
  
  display.clearDisplay();
  display.display();

  int duration = 0;
  while (true) {
    if (digitalRead(8) == LOW) {
      printClock(oldHour, oldMinute);
      delay(900);
      printClock(0, oldMinute);
      delay(900);
    } else if (digitalRead(8) == HIGH) {
      duration++;
      Serial.println(duration);
      delay(50);
      if ((duration > 1) && (duration < 2)) {
        Serial.println("it works");
        duration = 0;
        oldHour++; 
      }
    }
  }
}

It doesn't do much because I couldn't even get passed the first part of increasing the hour by one each button press. The code doesn't work at all, but I did make an attempt :I. Any help would be appreciated. Thank you!

Any help would be appreciated.

I rarely suggest using a library to do something simple like reading the state of a switch. However, your code will never work, riddled with delay()s like it is. Look at the Bounce2 (or other) library(s) for reading switches. Some of them handle short presses and long presses, with call backs for each.

One thing that I can assure of is that attempting to set a clock with only one button will be a horrible experience for the user. Much better is either to derive the time from an external time source ( internet NTP, radio clock etc.). Failing that, use a cheap infra red remote control e.g. IR Infrared Remote Control