[Alarms & Timers] Fix dow handling for timers

pull/1881/head
Alessandro Cocco 2022-05-25 23:13:37 +02:00
parent 67716aea63
commit 280fd5e665
1 changed files with 5 additions and 5 deletions

View File

@ -37,8 +37,8 @@ function handleFirstDayOfWeek(dow) {
return dow; return dow;
} }
// Check the first day of week and update the dow field accordingly. // Check the first day of week and update the dow field accordingly (alarms only!)
alarms.forEach(alarm => alarm.dow = handleFirstDayOfWeek(alarm.dow)); alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
function showMainMenu() { function showMainMenu() {
const menu = { const menu = {
@ -158,14 +158,14 @@ function saveAlarm(alarm, alarmIndex, time) {
} }
function saveAndReload() { function saveAndReload() {
// Before saving revert the dow to the standard format // Before saving revert the dow to the standard format (alarms only!)
alarms.forEach(a => a.dow = handleFirstDayOfWeek(a.dow, firstDayOfWeek)); alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
require("sched").setAlarms(alarms); require("sched").setAlarms(alarms);
require("sched").reload(); require("sched").reload();
// Fix after save // Fix after save
alarms.forEach(a => a.dow = handleFirstDayOfWeek(a.dow, firstDayOfWeek)); alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
} }
function decodeDOW(alarm) { function decodeDOW(alarm) {