Timer ON and OFF with RTC

Hi everyone, I have a proyect to turn ON and OFF a light at a time setted by the user. The user could change the time when ever he wants.
I wrote a code but it isn't workin. I just want to know if the logic is OK

I attach the code of the function here.

Thanks!

void Light_ON_OFF(void)
{
  byte hs_actual=rtc.getHours();
  byte min_actual=rtc.getMinutes();
  
  //Declare aux variables to concatenate hours and minutes to treat them as only 1 variable		
  int aux_setted_off, aux_setted_on, actual

  aux_setted_off=encendido=actual=0;
	
  //Concatenates hour and minutes. Setted by te user and the actual time
  aux_setted_off=hs_setted_off*100+min_setted_off;
  aux_setted_on=hs_setted_on*100+min_setted_on;
  aux_actual=hs_actual*100+min_actual;
  
  if(aux_setted_off<aux_setted_on)
  {
    if(aux_actual>=aux_setted_off && aux_actual<aux_setted_on)
      digitalWrite(PIN_LIGHT, 0); //Turn lights OFF
    else
      digitalWrite(PIN_LIGHT, 1); //Turn lights ON
  }

  if(aux_setted_off>aux_setted_on)
  {
    if(aux_actual>=aux_setted_on && aux_actual<aux_setted_off)
      digitalWrite(PIN_LIGHT, 1); //Turn lights ON
    else
      digitalWrite(PIN_LIGHT, 0); //Turn lights OFF
  }

}

ON_OFF.c (960 Bytes)

Thats a bit confusing so i shall just like my code, which uses the DS3231.

the variables are just simple ints

int onTimeHour = 23;
int onTimeMin = 0;
int offTimeHour = 22;
int offTimeMin = 30;
int lightMode = 1; // swaps when the toggle button is pressed "on/auto/off", code not included...

// ================================================= LIGHT
  if (lightMode == 0) { // timer mode
    if (onTimeHour == t.hour && onTimeMin ==  t.min) {
      digitalWrite(light_pin, LOW);
    }
    else if (offTimeHour == t.hour && offTimeMin ==  t.min) {
      digitalWrite(light_pin, HIGH);
    }
  }
  else if (lightMode == 1) { // constant on
    digitalWrite(light_pin, LOW);
  }
  else if (lightMode == 2) { // constant off
    digitalWrite(light_pin, HIGH);
  }

Calculating the number of minutes since midnight that it is now, or that the lights should be turned on or off, makes the comparison of now to then so much simpler.