Time

Enum Time 

Source
#[non_exhaustive]
pub enum Time {
Show 14 variants Century, Decade, Year, Week, Day, Hour, Minute, Second, Decisecond, Centisecond, Millisecond, Microsecond, Nanosecond, Picosecond,
}
Expand description

A unit of time.

The listed abbreviations are the abbreviations used to parse the unit with FromStr. The main abbreviation comes first, followed by any alternate abbreviations that can be used.

The conversions are listed in terms of the base unit. The base unit for Time is Time::Second.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Century

100 years, each of 365.25 days.

  • Abbreviation: cen

  • 1 cen = 3.15576e9 s

§

Decade

10 years, each of 365.25 days.

  • Abbreviation: dec

  • 1 dec = 3.15576e8 s

§

Year

A year of 365.25 days. Decades and centuries are defined in terms of this unit.

  • Abbreviation: yr

  • 1 yr = 3.15576e7 s

§

Week

  • Abbreviation: wk

  • 1 wk = 604800.0 s

§

Day

  • Abbreviation: day

  • 1 day = 86400.0 s

§

Hour

  • Abbreviation: hr

  • 1 hr = 3600.0 s

§

Minute

  • Abbreviation: min

  • 1 min = 60.0 s

§

Second

  • Abbreviation: s

  • 1 s = 1.0 s

§

Decisecond

  • Abbreviation: ds

  • 1 ds = 0.1 s

§

Centisecond

  • Abbreviation: cs

  • 1 cs = 0.01 s

§

Millisecond

  • Abbreviation: ms

  • 1 ms = 0.001 s

§

Microsecond

  • Abbreviation: µs, us

  • 1 µs = 1e-6 s

§

Nanosecond

  • Abbreviation: ns

  • 1 ns = 1e-9 s

§

Picosecond

  • Abbreviation: ps

  • 1 ps = 1e-12 s

Implementations§

Source§

impl Time

Source

pub fn pow(&self, power: i8) -> Unit

Creates a Unit with this quantity type and specified power.

Source

pub fn squared(&self) -> Unit

Creates a Unit with this quantity type and power 2.

Source

pub fn cubed(&self) -> Unit

Creates a Unit with this quantity type and power 3.

Trait Implementations§

Source§

impl Clone for Time

Source§

fn clone(&self) -> Time

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Convert for Time

Source§

const BASE: Self = Time::Second

The base unit of this unit. Read more
Source§

fn conversion_factor(&self) -> f64

Returns the conversion factor from &self to Convert::BASE, i.e. the value to multiply a quantity in this unit by, in order to get a quantity in Convert::BASE. If the self unit is the same as this unit, then this function should return 1.0. Read more
Source§

fn conversion_factor_to(&self, _: impl Into<Unit>) -> Option<f64>

Defines the conversion factor from Convert::BASE, to a base unit that Convert::BASE is derived from. Returns None if there is no conversion factor, meaning the two units are unrelated. Read more
Source§

impl Debug for Time

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Time

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Time> for Base

Source§

fn from(u: Time) -> Self

Converts to this type from the input type.
Source§

impl From<Time> for CompoundUnit

Source§

fn from(u: Time) -> Self

Converts to this type from the input type.
Source§

impl From<Time> for Unit

Source§

fn from(u: Time) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Time

Source§

type Err = InvalidUnit

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Time

Source§

fn eq(&self, other: &Time) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&str> for Time

Source§

type Error = InvalidUnit

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Time

Source§

impl Eq for Time

Source§

impl StructuralPartialEq for Time

Auto Trait Implementations§

§

impl Freeze for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnwindSafe for Time

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.