use crate::convert::*;
use crate::Duration;
mod sealed {
pub trait Sealed {}
impl Sealed for i64 {}
impl Sealed for f64 {}
}
pub trait NumericalDuration: sealed::Sealed {
fn nanoseconds(self) -> Duration;
fn microseconds(self) -> Duration;
fn milliseconds(self) -> Duration;
fn seconds(self) -> Duration;
fn minutes(self) -> Duration;
fn hours(self) -> Duration;
fn days(self) -> Duration;
fn weeks(self) -> Duration;
}
impl NumericalDuration for i64 {
fn nanoseconds(self) -> Duration {
Duration::nanoseconds(self)
}
fn microseconds(self) -> Duration {
Duration::microseconds(self)
}
fn milliseconds(self) -> Duration {
Duration::milliseconds(self)
}
fn seconds(self) -> Duration {
Duration::seconds(self)
}
fn minutes(self) -> Duration {
Duration::minutes(self)
}
fn hours(self) -> Duration {
Duration::hours(self)
}
fn days(self) -> Duration {
Duration::days(self)
}
fn weeks(self) -> Duration {
Duration::weeks(self)
}
}
impl NumericalDuration for f64 {
fn nanoseconds(self) -> Duration {
Duration::nanoseconds(self as _)
}
fn microseconds(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Microsecond) as Self) as _)
}
fn milliseconds(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Millisecond) as Self) as _)
}
fn seconds(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Second) as Self) as _)
}
fn minutes(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Minute) as Self) as _)
}
fn hours(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Hour) as Self) as _)
}
fn days(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Day) as Self) as _)
}
fn weeks(self) -> Duration {
Duration::nanoseconds((self * Nanosecond::per(Week) as Self) as _)
}
}