mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Update timespan.rs
This commit is contained in:
parent
4e1f0d8726
commit
190e37eecb
1 changed files with 4 additions and 9 deletions
|
@ -111,15 +111,10 @@ 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,
|
||||
pub fn to_unit(self, unit: TimespanUnit) -> Timespan {
|
||||
Timespan {
|
||||
seconds: self.seconds,
|
||||
unit,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue