Use absolute time instead of incrementing by 1w

This commit is contained in:
2022-10-27 23:36:25 +02:00
parent 1ac0dbe210
commit 1e55385645

View File

@ -142,13 +142,12 @@ async fn wake_task(
day: Weekday, day: Weekday,
time: NaiveTime, time: NaiveTime,
) { ) {
let now = Local::now(); let mut alarm = next_alarm(Local::now(), day, time);
let mut alarm = next_alarm(now, day, time);
loop { loop {
info!("sleeping until {alarm}"); info!("sleeping until {alarm}");
sleep((alarm - now).to_std().unwrap()).await; sleep((alarm - Local::now()).to_std().unwrap()).await;
alarm += chrono::Duration::weeks(1); alarm = next_alarm(Local::now(), day, time);
// slowly turn up brightness of bulb // slowly turn up brightness of bulb
for brightness in (1..=75).map(|i| (i as f32) * 0.01) { for brightness in (1..=75).map(|i| (i as f32) * 0.01) {