sched: Ensure dow wrap, Sa(6)+1 = Su(0)

pull/1675/head
storm64 2022-04-09 14:46:08 +02:00
parent 9ab2fcdf31
commit c4b7c798d2
1 changed files with 1 additions and 1 deletions

View File

@ -38,7 +38,7 @@ exports.getTimeToAlarm = function(alarm, time) {
if (!alarm) return undefined;
if (!time) time = new Date();
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;
var t = alarm.t-currentTime;
if (alarm.last == time.getDate() || t < -60000) t += 86400000;