sched: Fix `getTimeToAlarm` for timers
Only set `last` for alarms to prevent a wrong output of `getTimeToAlarm` for a timer already used at same day.master
parent
0dcc0ec789
commit
2c729af68c
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Fix scheduling of other alarms if there is a pending alarm from the past (fix #1667)
|
0.02: Fix scheduling of other alarms if there is a pending alarm from the past (fix #1667)
|
||||||
|
0.03: Fix `getTimeToAlarm` for a timer already used at same day, don't set `last` for timers.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ Alarms are stored in an array in `sched.json`, and take the form:
|
||||||
date : "2022-04-04", // OPTIONAL date for the alarm, in YYYY-MM-DD format
|
date : "2022-04-04", // OPTIONAL date for the alarm, in YYYY-MM-DD format
|
||||||
// eg (new Date()).toISOString().substr(0,10)
|
// eg (new Date()).toISOString().substr(0,10)
|
||||||
msg : "Eat food", // message to display.
|
msg : "Eat food", // message to display.
|
||||||
last : 0, // last day of the month we alarmed on - so we don't alarm twice in one day!
|
last : 0, // last day of the month we alarmed on - so we don't alarm twice in one day! (No change from 0 on timers)
|
||||||
rp : true, // repeat the alarm every day?
|
rp : true, // repeat the alarm every day?
|
||||||
vibrate : "...", // OPTIONAL pattern of '.', '-' and ' ' to use for when buzzing out this alarm (defaults to '..' if not set)
|
vibrate : "...", // OPTIONAL pattern of '.', '-' and ' ' to use for when buzzing out this alarm (defaults to '..' if not set)
|
||||||
hidden : false, // OPTIONAL if false, the widget should not show an icon for this alarm
|
hidden : false, // OPTIONAL if false, the widget should not show an icon for this alarm
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ exports.setAlarm = function(id, alarm) {
|
||||||
}
|
}
|
||||||
exports.setAlarms(alarms);
|
exports.setAlarms(alarms);
|
||||||
};
|
};
|
||||||
/// Get time until the given alarm (object). Return undefined if alarm not enabled, or if 86400000 or more, alarm could me *more* than a day in the future
|
/// Get time until the given alarm (object). Return undefined if alarm not enabled, or if 86400000 or more, alarm could be *more* than a day in the future
|
||||||
exports.getTimeToAlarm = function(alarm, time) {
|
exports.getTimeToAlarm = function(alarm, time) {
|
||||||
if (!alarm) return undefined;
|
if (!alarm) return undefined;
|
||||||
if (!time) time = new Date();
|
if (!time) time = new Date();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "sched",
|
"id": "sched",
|
||||||
"name": "Scheduler",
|
"name": "Scheduler",
|
||||||
"version": "0.02",
|
"version": "0.03",
|
||||||
"description": "Scheduling library for alarms and timers",
|
"description": "Scheduling library for alarms and timers",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "scheduler",
|
"type": "scheduler",
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ function showAlarm(alarm) {
|
||||||
if(alarm.ot===undefined) alarm.ot = alarm.t;
|
if(alarm.ot===undefined) alarm.ot = alarm.t;
|
||||||
alarm.t += 10*60*1000; // 10 minutes
|
alarm.t += 10*60*1000; // 10 minutes
|
||||||
} else {
|
} else {
|
||||||
alarm.last = (new Date()).getDate();
|
if (!alarm.timer) alarm.last = (new Date()).getDate();
|
||||||
if (alarm.ot!==undefined) {
|
if (alarm.ot!==undefined) {
|
||||||
alarm.t = alarm.ot;
|
alarm.t = alarm.ot;
|
||||||
delete alarm.ot;
|
delete alarm.ot;
|
||||||
|
|
|
||||||
2
core
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit b04f32553935f1479ad226ce1b2cff4f4b2e1a6f
|
Subproject commit e9097fa680182069a5814c3e566a0bcbcb5e72a1
|
||||||
Loading…
Reference in New Issue