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 {