From 1dfc09cb6b2d3522733bf4faf6fe3cda98d70308 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Fri, 4 Sep 2020 14:33:33 +0200 Subject: [PATCH] tools/systemd/time: fix signed conversion instead of using 'as' and silently converting wrong, use the TryInto trait and raise an error if we cannot convert this should only happen if we have a negative year, but this is expected (we do not want schedules from before the year 0) Signed-off-by: Dominik Csapak --- src/tools/systemd/time.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/tools/systemd/time.rs b/src/tools/systemd/time.rs index 69f5f5fb..7717ecee 100644 --- a/src/tools/systemd/time.rs +++ b/src/tools/systemd/time.rs @@ -1,3 +1,5 @@ +use std::convert::TryInto; + use anyhow::Error; use bitflags::bitflags; @@ -174,17 +176,17 @@ pub fn compute_next_event( } if !all_days { // match day first - let day_num = t.day_num(); + let day_num: u32 = t.day_num().try_into()?; let day = WeekDays::from_bits(1<