conveniently convert Time into float

This commit is contained in:
2026-02-26 08:53:42 -08:00
parent 36f44ffd43
commit bfe4b491d7

View File

@@ -153,6 +153,16 @@ impl<T> core::ops::Mul<Time<T>> for Planar64{
Ratio::new(self*Fixed::raw(rhs.0),Planar64::raw(1_000_000_000))
}
}
impl<T> From<Time<T>> for f32{
fn from(value:Time<T>)->Self{
value.get() as f32/Time::<T>::ONE_SECOND.get() as f32
}
}
impl<T> From<Time<T>> for f64{
fn from(value:Time<T>)->Self{
value.get() as f64/Time::<T>::ONE_SECOND.get() as f64
}
}
#[cfg(test)]
mod test_time{
use super::*;