Time based interrupts using an RTC

I'm over my head on this. I was planning to automate my water pump system, and wanted to put all of the code within a time based loop, which would immediately stop in the evening (because electricity costs more then) using a DS1307.
However, I'm lost on how to structure the code this way.
Help would be greatly appreciated :).

I think your use of the word "interrupts" is inappropriate because an interrupt has a very particular technical meaning for Arduino programming that does not seem relevant to your problem.

It seems to me you just need code that repeatedly checks the time and if it gets to X then it turns off the pump. If I was managing the time with millis() it would be something simple like this

if (millis() - pumpStartTime >= pumpOnTime) {
   // code to stop the pump
}

It should be possible to do something equivalent using the time from the RTC module - perhaps something like

if (rtc.now() >= XXX {
   // code to stop the pump
}

It will be much easier to help if you post the program that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different. Then we can focus on the parts you need help with rather than wasting time on things that you can do.

...R

Robin2:
It should be possible to do something equivalent using the time from the RTC module - perhaps something like

if (rtc.now() >= XXX {

// code to stop the pump
}

And if this is a daily occurance, rather than use rtc.now(), calculate the time of day. It is easiest to do all this as seconds

const unsigned int startTime = 6 * 24 * 60; // 6am
const unsigned int endTime = 20 * 24 * 60 + 30 * 60; // 8:30pm

unsigned int timeOfDay = rtc.hour() * 24 * 60 + rtc.minute() * 60 + rtc.second();
if ( timeOfDay >= startTime && timeOfDay < endTime ) {
  // do daytime things
} else {
  // do nighttime things
}

The very simplest solution, which only works on hour boundaries, is to only read hours from the RTC, use a change of state detection to trigger the on/off actions when certain hours change, e.g. on when the hour changes from 5 to 6, off when it changes from 20 to 21. The code for that is relatively simple.

blh64:
And if this is a daily occurance, rather than use rtc.now(), calculate the time of day. It is easiest to do all this as seconds

I'm not familiar with the library. I thought rtc.now() did give the value in seconds

...R

Robin2:
I'm not familiar with the library. I thought rtc.now() did give the value in seconds

...R

It does, just not seconds past midnight...