Any suggestions?
WB
AFAICT; you have two choices, you could either develop the algorithm
to satisfy your conditions, and hard code that into your program, or,
you could use some ad hoc calendering mechanism to mark the times
and durations you need.
How you go about that is up to you, but devising a calendering method
would be more robust if you eve wanted to allow for altering the triggers.
If your triggers are on an hourly basis (day to day) then you need to
have a calander that covers at least one day, which you use over and
over for each day. If you have triggers that happen on specific days
of the week then you need a calander that covers at least a week which
you can use week to week. If your triggers only happen in a specific
month, then you need to cover the entire year, and so on, building
the calander to cover one 'level' up from your desired repeat rate.
Since you want to trigger on specific hours of specific days, (presumably
wekk after week, all year long), then you'd need a calander than covers
hours in a day as well as days in a week.
How you do that is up to you. You might simply need to mark the
triggered hours (one bit in a long would suffice), or you might need
to store more information for each trigger (which may be a string,
or other such adjustable medium) in each hour of the day.
I'd suggest to use your imagination, and be creative....
LFS
Scheduling sounds easy but it's not. You're basically taking (somewhat
loose) human language and trying to make it computer-usable. I implemented a
rather complex scheduling algorithm a while back that used two 32-bit
numbers as "compact storage*" for the schedule. The first number held the
large-scale schedule, which determined on what day of the month/year the
schedule was to occur, and the second held the time information for when it
would occur in a given day and how often it would repeat. Note that my
scheduler was merely for initiating events; it had no concept of a duration.
(In other words, it has the concept of "Something should happen at 3:00 AM
on the 1st Tuesday of every month," but not "Something happens from 3 - 4
AM.") That would require yet more data.
Beyond the description, though, I can't help you much, since I implemented
it in C#.
* Some bit flags plus a few areas which held numbers in 2 or more bits.