From 900429b3d142b4469b0a25d65145e598d7929571 Mon Sep 17 00:00:00 2001 From: user1823 <92206575+user1823@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:45:29 +0530 Subject: [PATCH] Update timespan.rs --- rslib/src/scheduler/timespan.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rslib/src/scheduler/timespan.rs b/rslib/src/scheduler/timespan.rs index a3a546149..7a4b9b4e4 100644 --- a/rslib/src/scheduler/timespan.rs +++ b/rslib/src/scheduler/timespan.rs @@ -111,6 +111,18 @@ impl Timespan { } } + /// Returns the value in the given unit + pub fn as_provided_unit(&self, unit: TimespanUnit) -> f32 { + match unit { + TimespanUnit::Seconds => self.seconds, + TimespanUnit::Minutes => self.seconds / MINUTE, + TimespanUnit::Hours => self.seconds / HOUR, + TimespanUnit::Days => self.seconds / DAY, + TimespanUnit::Months => self.seconds / MONTH, + TimespanUnit::Years => self.seconds / YEAR, + } + } + /// Round seconds and days to integers, otherwise /// truncates to one decimal place. pub fn as_rounded_unit(self) -> f32 {