Update timespan.rs

This commit is contained in:
user1823 2025-08-06 14:40:52 +05:30 committed by GitHub
parent 4e1f0d8726
commit 190e37eecb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -111,15 +111,10 @@ impl Timespan {
} }
} }
/// Returns the value in the given unit pub fn to_unit(self, unit: TimespanUnit) -> Timespan {
pub fn as_provided_unit(&self, unit: TimespanUnit) -> f32 { Timespan {
match unit { seconds: self.seconds,
TimespanUnit::Seconds => self.seconds, unit,
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,
} }
} }