Nodejs 定时器 later 怎么运行自己创建的 schedule
代码如下。求指导。
var later = require('later');
later.date.localTime();
console.log("Now:"+new Date());
var basic = {h: [8,9,10,11,12,13,14,15,16,17], s: [0,15,30,45]};
var composite = [
basic,
{h: [18], m: [0]}
];
var exception = [
{dw: [6,7]}
];
later.date.localTime();
var schedule = {
schedules:composite,
exceptions:exception
};
later.date.localTime();
var sched = later.schedule(schedule),
//var sched = later.parse.recur().on(schedu),
t = later.setInterval(test, sched),
count = 5;
function test() {
console.log(new Date());
if(count <= 0) {
t.clear();
}
}
2 回复
later.setInterval(test, sched),
已经运行了啊…
later.setTimeout(function() {}, sched) // 运行一次.
later.setInterval(test, sched), //一直运行