use super::TimeModifiers;
use std::cmp::Ordering;
#[derive(Clone, Debug, PartialEq)]
pub struct TimeStamp {
pub amount: f64,
}
impl TimeStamp {
pub fn new(amount: f64) -> Self {
Self { amount }
}
pub fn from_seconds(seconds: isize) -> Self {
Self::new(seconds as f64)
}
}
impl TimeModifiers for TimeStamp {
fn add_millis(&self, amount: isize) -> Self {
Self::new(self.amount + (amount as f64) * 1.0e-3)
}
fn add_nanos(&self, amount: isize) -> Self {
Self::new(self.amount + (amount as f64) * 1.0e-9)
}
}
impl PartialOrd for TimeStamp {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.amount.partial_cmp(&other.amount)
}
}