Time adjust for hours not working

I am sure I am missing something simple, but I have looked for quite some time now.

My clock adjust works for minutes, and the hour rolls over just fine. But I could swear the hour adjust is written just like the minute adjust… but it doesn’t. I have verified that the debounce and inputs work with the Serial.println in each adjust if/then.

What have I missed?

Thanks for any help.

// include the library code:
#include <LiquidCrystal.h>
#include <Time.h>
#include <DS3232RTC.h>



// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int hours;
int minutes;
int seconds;

const int hourButtonPin = 7;    // the number of the pushbutton pins
const int minButtonPin = 8;
int hourButtonState;             // the current reading from the input pin
int lastHourButtonState;   // the previous reading from the input pin
int minButtonState;             // the current reading from the input pin
int lastMinButtonState;   // the previous reading from the input pin

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  pinMode(hourButtonPin, INPUT_PULLUP);
  pinMode(minButtonPin, INPUT_PULLUP);
  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("The time is:");
  Serial.begin(9600);
  
   setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet) {
    lcd.setCursor(0,1);
     Serial.println("Sync failed");
     lcd.print("Unable to sync with the RTC");}
  else
     Serial.println("RTC has set the system time");  

}

void loop() {
  hours = hourFormat12();
  minutes = minute();
  seconds = second();
  // read the state of the switch into a local variable:
  int hourReading = digitalRead(hourButtonPin);
  if (hourReading != lastHourButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
   if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (hourReading != hourButtonState) {
      hourButtonState = hourReading;

      //If the button state is low, adjust time 3600 seconds
      if (hourButtonState == LOW) {
        adjustTime(3600);
        RTC.set(now());
        Serial.println("hour"); //Verify button press on serial monitor
      }
    }
  }
  // read the state of the switch into a local variable:
  int minReading = digitalRead(minButtonPin);
  if (minReading != lastMinButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
   if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (minReading != minButtonState) {
      minButtonState = minReading;

      // If button state is low, adjust time 60 seconds
      if (minButtonState == LOW) {
        adjustTime(60);
        RTC.set(now());
        Serial.println("minute"); //Verify button press on serial monitor
      }
    }
  }
  
 lastHourButtonState = hourReading;
 lastMinButtonState = minReading;
  
  // Output time on LCD
  lcd.setCursor(0, 1);
  // print the time
  if (hours < 10){
    lcd.print (0);
  }
  
  lcd.print(hours);
  lcd.print(":");
  if (minutes <10){
    lcd.print(0);
  }
  lcd.print(minutes);
  lcd.print(":");
  if (seconds <10){
    lcd.print(0);
  }
  lcd.print(seconds);
}
  int hourReading = digitalRead(hourButtonPin);
  if (hourReading != lastHourButtonState) {

Wouldn't currHourState and prevHourState make more sense? There is no way that comparing reading to state makes sense.

    if (hourReading != hourButtonState) {
      hourButtonState = hourReading;

Nonsense. You do NOT need three variables to keep track of the current and previous state of ANY pin.

You DO need separate debounce time variables for the two pins.

        adjustTime(3600);
        RTC.set(now());

Why doesn't adjustTime() actually adjust the time?

What have I missed?

The rest of your code.

PaulS:
Wouldn't currHourState and prevHourState make more sense? There is no way that comparing reading to state makes sense.

I suppose it might make more sense. But the names mean nothing to the compiler, correct? I could call them GreenMonkeys and BlueMonkeys.

Nonsense. You do NOT need three variables to keep track of the current and previous state of ANY pin.

You DO need separate debounce time variables for the two pins.

I guess it is clear that programming is not my strong point. That is exactly like the debounce tutorial. Is there a better way you can point me to?

Why doesn't adjustTime() actually adjust the time?

adjustTime(60) does work. See http://playground.arduino.cc/code/time But adjustTime(3600) doesn't.

I suppose it might make more sense.

It would.

But the names mean nothing to the compiler, correct?

You didn't ask the compiler to comment on your code. You asked for people to comment on your code.

That is exactly like the debounce tutorial.

Which was developed to show (poorly, in my opinion) how to debounce one switch.

adjustTime(60) does work. ... But adjustTime(3600) doesn't.

So, THAT's why you didn't post the code. I was wondering...