sched: Ensure dow wrap, Sa(6)+1 = Su(0)
parent
9ab2fcdf31
commit
c4b7c798d2
|
|
@ -38,7 +38,7 @@ exports.getTimeToAlarm = function(alarm, time) {
|
||||||
if (!alarm) return undefined;
|
if (!alarm) return undefined;
|
||||||
if (!time) time = new Date();
|
if (!time) time = new Date();
|
||||||
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
|
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
|
||||||
var active = alarm.on && (alarm.dow>>(time.getDay()+(alarm.t<currentTime)))&1 && (!alarm.date || alarm.date==time.toISOString().substr(0,10));
|
var active = alarm.on && (alarm.dow>>((time.getDay()+(alarm.t<currentTime))%7))&1 && (!alarm.date || alarm.date==time.toISOString().substr(0,10));
|
||||||
if (!active) return undefined;
|
if (!active) return undefined;
|
||||||
var t = alarm.t-currentTime;
|
var t = alarm.t-currentTime;
|
||||||
if (alarm.last == time.getDate() || t < -60000) t += 86400000;
|
if (alarm.last == time.getDate() || t < -60000) t += 86400000;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue