]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tools/systemd/tm_editor: remove reset_time from add_days and document it
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 4 Sep 2020 12:33:28 +0000 (14:33 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2020 13:28:24 +0000 (15:28 +0200)
we never passed 'false' to it anyway so remove it
(we can add it again if we should ever need it)

also remove the adding of wday (gets normalized anyway)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/tools/systemd/time.rs
src/tools/systemd/tm_editor.rs

index 2e99e289550c7bbb5e94617122836a4654872a5e..c8cc8468a898204654233d87282b50e7b3d8fd0b 100644 (file)
@@ -181,10 +181,10 @@ pub fn compute_next_event(
                     .find(|d| event.days.contains(WeekDays::from_bits(1<<d).unwrap()))
                 {
                     // try next day
-                    t.add_days(n - day_num, true)?;
+                    t.add_days(n - day_num,)?;
                 } else {
                     // try next week
-                    t.add_days(7 - day_num, true)?;
+                    t.add_days(7 - day_num)?;
                 }
                 continue;
             }
@@ -199,7 +199,7 @@ pub fn compute_next_event(
                     t.set_time(n as libc::c_int, 0, 0)?;
                 } else {
                     // test next day
-                    t.add_days(1, true)?;
+                    t.add_days(1)?;
                 }
                 continue;
             }
index 4a14a97565bf8337adca786daeeaad6fd91bf38c..b098f1cb13bb88fb4b4113760a50e8c0045bc7d8 100644 (file)
@@ -21,15 +21,13 @@ impl TmEditor {
         Ok(epoch)
     }
 
-    pub fn add_days(&mut self, days: libc::c_int, reset_time: bool) -> Result<(), Error> {
+    /// increases the day by 'days' and resets all smaller fields to their minimum
+    pub fn add_days(&mut self, days: libc::c_int) -> Result<(), Error> {
         if days == 0 { return Ok(()); }
-        if reset_time {
-            self.t.tm_hour = 0;
-            self.t.tm_min = 0;
-            self.t.tm_sec = 0;
-        }
+        self.t.tm_hour = 0;
+        self.t.tm_min = 0;
+        self.t.tm_sec = 0;
         self.t.tm_mday += days;
-        self.t.tm_wday += days;
         self.normalize_time()
     }