pub enum Unit {
Nanosecond,
Microsecond,
Millisecond,
Second,
Minute,
Hour,
Day,
Week,
Century,
}Expand description
An Enum to perform time unit conversions.
Variants§
Nanosecond
Microsecond
Millisecond
Second
Minute
Hour
Day
Week
Century
36525 days, is the number of days per century in the Julian calendar
Implementations§
Source§impl Unit
impl Unit
pub fn in_seconds(&self) -> f64
pub fn from_seconds(&self) -> f64
Trait Implementations§
Source§impl AddAssign<Unit> for Duration
impl AddAssign<Unit> for Duration
Source§fn add_assign(&mut self, rhs: Unit)
fn add_assign(&mut self, rhs: Unit)
Performs the
+= operation. Read moreSource§impl AddAssign<Unit> for Epoch
impl AddAssign<Unit> for Epoch
Source§fn add_assign(&mut self, unit: Unit)
fn add_assign(&mut self, unit: Unit)
Performs the
+= operation. Read moreSource§impl From<u8> for Unit
Allows conversion of a u8 into a Unit. Defaults to Second if the u8 is not a valid Unit representation.
impl From<u8> for Unit
Allows conversion of a u8 into a Unit. Defaults to Second if the u8 is not a valid Unit representation.
Source§impl Mul<f64> for Unit
impl Mul<f64> for Unit
Source§fn mul(self, q: f64) -> Duration
fn mul(self, q: f64) -> Duration
Creates a duration from that f64
§Limitations
- If the input value times the unit does not fit on a Duration, then Duration::MAX or Duration::MIN will be returned depending on whether the value would have overflowed or underflowed (respectively).
- Floating point operations may round differently on different processors. It’s advised to use integer initialization of Durations whenever possible.
Source§impl Ord for Unit
impl Ord for Unit
Source§impl PartialOrd<Unit> for Duration
impl PartialOrd<Unit> for Duration
Source§impl PartialOrd for Unit
impl PartialOrd for Unit
Source§impl SubAssign<Unit> for Duration
impl SubAssign<Unit> for Duration
Source§fn sub_assign(&mut self, rhs: Unit)
fn sub_assign(&mut self, rhs: Unit)
Performs the
-= operation. Read moreSource§impl SubAssign<Unit> for Epoch
impl SubAssign<Unit> for Epoch
Source§fn sub_assign(&mut self, unit: Unit)
fn sub_assign(&mut self, unit: Unit)
Performs the
-= operation. Read moreimpl Copy for Unit
impl Eq for Unit
impl StructuralPartialEq for Unit
Auto Trait Implementations§
impl Freeze for Unit
impl RefUnwindSafe for Unit
impl Send for Unit
impl Sync for Unit
impl Unpin for Unit
impl UnwindSafe for Unit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more