Trigger functions at recurring times

Instead of code, I am looking for a methodology.

My original approach was if current_datetime == scheduled_datetime then trigger. The problem with this approach is that sometimes the board skips a few beats/seconds (could be because of WiFi, etc - I don't really know). I believe I can't avoid this so I need to go a route where if current_datetime is past scheduled_datetime then trigger (this will catch up if the board got stuck for a few seconds here or there).

Requirement: The trigger happens one or more days of the week at the same exact time. This is the input to the program. The user has the ability to change the schedule at any time.
Example 3:00pm Tuesday and Thursday OR 5:00am Saturday and Sunday.

Crude Approach: Without a library, with the input I have (3:00pm Tuesday and Thursday), if I can build a list/queue of exact DateTimes for future events I can then easily do the comparison (of if current_datetime is past scheduled_datetime then trigger). After triggering, I will re-build the list/queue.
My challenge here is that if today is 11/1/2018 5:00pm, how do I get the DateTime (date part) for the next few 3:00pm Tuesday and Thursday to keep in my list/queue.

Library Approach: It looks like there is an TimeAlarm library available. Specifically the function in there Alarm.alarmRepeat(dowTuesday, 15,00,0, TuesdayTrigger). It seems like this will trigger on Tuesdays at 3:00pm. I am hoping this will catch up missed alarms if the board got stuck for a few seconds. My challenge here is that I don't see a way to cancel the existing ones if the end user decided to change the input/schedule.

I would appreciate any help!

if ((currentDateTime >= scheduledDateTimeBegin) && (currentDateTime < scheduledDateTimeEnd))

?

Do you understand how an RTC can be used in timing?
Have you reviewed the Time library?

https://playground.arduino.cc/Code/Time

evanmars:

if ((currentDateTime >= scheduledDateTimeBegin) && (currentDateTime < scheduledDateTimeEnd))

?

The input I have is 3:00 PM Tuesdays and Thursdays.

From that I don't know how I can go to 10/2/2017 3:00 PM. If I can somehow, then that would be scheduledDateTimeBegin and your example would work.

larryd:
Do you understand how an RTC can be used in timing?
Have you reviewed the Timer library?

I actually have the RTC module with battery and I am using it to get the current time for the board.

I am using the Timer library too at other places. It simply sets a trigger for future x seconds. My challenge is that I don't know how many seconds between now and when I need to trigger. I have the current date and time but when I need to trigger I only have the time and days (3:00 PM Tuesday and Thursday). If I had 10/2/2017 3:00 PM I could do it easily.

I am familiar with Time library.