From eed8a5ad79db35d20f82ccdd817938581b66e834 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 3 Jun 2020 16:34:06 +0200 Subject: [PATCH] tools/systemd/time: fix compute_next_event for weekdays two things were wrong here: * the range (x..y) does not include y, so the range (day_num+1..6) goes from (day_num+1) to 5 (but sunday is 6) * WeekDays.bits() does not return the 'day_num' of that day, but the bit value (e.g. 64 for SUNDAY) but was treated as the index of the day of the week to fix this, we drop the map to WeekDays and use the 'indices' directly this patch makes the test work again Signed-off-by: Dominik Csapak --- src/tools/systemd/time.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tools/systemd/time.rs b/src/tools/systemd/time.rs index 81ea00f0..910e9033 100644 --- a/src/tools/systemd/time.rs +++ b/src/tools/systemd/time.rs @@ -163,12 +163,11 @@ pub fn compute_next_event( if event.days.contains(day) { t.changes.remove(TMChanges::WDAY); } else { - if let Some(n) = (day_num+1..6) - .map(|d| WeekDays::from_bits(1<