DayTimer make things happen at specific times of the day/hour/minute
class methods
*new(name, id, test, func);
access or make a new DayTimer for the given name;
optionally give it an id underwhich to store a daytime task.
DayTimer(\otto);
*all
DayTimer.all; // all daytimers are stored here.
*top // top is a class variable; this daytimer is for general tasks.
// for only one global control of daytime-bound tasks, this is simplest.
// when one wants to turn groups of date/tasks on and off,
// it is easiest to put them in separate named daytimers.
DayTimer.top;
// many class methods are redirected as instance methods to DayTimer.top;
// for details, see below.
*start // actually does DayTimer.top.start;
*stop
*putDate(id, test, func) // add a task to DayTimer.top.
*removeAt(key) // remove a task from DayTimer.top
instance methods:
d = DayTimer(\otto);
stop, start
d.stop; // stop watching for dates
d.start; // start watching for dates
putDate(id, test, func);
put in a date with a task:
id is a symbol (used for ID when removing or overwriting a date),
test is either a time in [<hour>, <min>, <sec>],
or a function that tests a date object with the time now (Date.getDate).
func is the task to do when test == true.
// do this every full minute - id so you can remove it again
d.putDate(\perMin, { |date| date.second == 0 }, { "full minute!".postln });
// do this every minute at seconds 25 and 35
d.putDate(\min2, { |date| [25, 35].includes(date.second) }, { "twice a min".postln });
( // do this every third minute
d.putDate(\min3,
{ |date| (date.minute * 60 + date.second) % 180 == 60 },
{ "every 3 minutes".postln });
)
// once a day at a specific time [h, m, s] -
// maybe set this to the next full minute for testing
d.putDate(\onceT, [12, 35, 40], { "once a day only!".postln } );
// daytimer tests and posts when a function fails,
// but continues watching.
d.putDate(\failZ, { |d| [20, 40].includes(d.second) }, { 1.blork });
removeAt(id);
// remove a date, here the failing date/task
d.removeAt(\failZ);
dates
// show all dates
DayTimer.top.dates.postcs;
d.dates.postcs;
skip
d.skip; // the skipjack that does the watching
name
d.name; // the daytimer's name