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 <d.csapak@proxmox.com>
This commit is contained in:
parent
538b9c1c27
commit
eed8a5ad79
@ -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<<d).unwrap())
|
||||
.find(|d| event.days.contains(*d))
|
||||
if let Some(n) = ((day_num+1)..7)
|
||||
.find(|d| event.days.contains(WeekDays::from_bits(1<<d).unwrap()))
|
||||
{
|
||||
// try next day
|
||||
t.add_days((n.bits() as i32) - day_num, true);
|
||||
t.add_days(n - day_num, true);
|
||||
continue;
|
||||
} else {
|
||||
// try next week
|
||||
|
Loading…
Reference in New Issue
Block a user