sched: add day of week check to getActiveAlarms()

pull/1792/head
Erik Andresen 2022-05-04 22:58:45 +02:00
parent 54f2017c23
commit 1d22050dc6
3 changed files with 8 additions and 3 deletions

View File

@ -6,4 +6,4 @@
0.06: Refactor some methods to library
0.07: Update settings
Correct `decodeTime(t)` to return a more likely expected time
0.08: add day of week check to getActiveAlarms()

View File

@ -15,7 +15,12 @@ exports.getActiveAlarms = function(alarms, time) {
if (!time) time = new Date();
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000)
+10000;// get current time - 10s in future to ensure we alarm if we've started the app a tad early
return alarms.filter(a=>a.on&&(a.t<currentTime)&&(a.last!=time.getDate()) && (!a.date || a.date==time.toISOString().substr(0,10))).sort((a,b)=>a.t-b.t);
return alarms.filter(a=>a.on
&&(a.t<currentTime)
&&(a.last!=time.getDate())
&& (!a.date || a.date==time.toISOString().substr(0,10))
&& a.dow >> (time).getDay() & 1))
.sort((a,b)=>a.t-b.t);
}
// Set an alarm object based on ID. Leave 'alarm' undefined to remove it
exports.setAlarm = function(id, alarm) {

View File

@ -1,7 +1,7 @@
{
"id": "sched",
"name": "Scheduler",
"version": "0.07",
"version": "0.08",
"description": "Scheduling library for alarms and timers",
"icon": "app.png",
"type": "scheduler",