Skip to main content

Time

Struct Time 

Source
pub struct Time(/* private fields */);
Expand description

A time duration quantity, stored canonically in seconds (s).

§Construction

use space_units::prelude::*;

let t = Time::from_hours(2.0);
let t2 = 2.0.hours();          // NumericExt shorthand

§Supported units

ConstructorAccessorUnit
from_sin_ssecond (s)
from_msin_msmillisecond (ms)
from_usin_usmicrosecond (us)
from_nsin_nsnanosecond (ns)
from_minin_minminute (min)
from_hoursin_hourshour (h)
from_daysin_daysday (d)
from_julian_yearsin_julian_yearsJulian year

§Typed arithmetic

Implementations§

Source§

impl Time

Source

pub const fn from_s(val: f64) -> Self

Create from seconds (canonical unit).

Source

pub const fn from_ms(val: f64) -> Self

Create from milliseconds. 1 ms = 0.001 s.

Source

pub const fn from_us(val: f64) -> Self

Create from microseconds. 1 us = 1e-6 s.

Source

pub const fn from_ns(val: f64) -> Self

Create from nanoseconds. 1 ns = 1e-9 s.

Source

pub const fn from_min(val: f64) -> Self

Create from minutes. 1 min = 60 s.

Source

pub const fn from_hours(val: f64) -> Self

Create from hours. 1 h = 3 600 s.

Source

pub const fn from_days(val: f64) -> Self

Create from days. 1 d = 86 400 s.

Source

pub const fn from_julian_years(val: f64) -> Self

Create from Julian years. 1 Julian year = 365.25 days.

Source

pub const fn in_s(self) -> f64

Get value in seconds.

Source

pub const fn in_seconds(self) -> f64

Get value in seconds (alias for in_s).

Source

pub const fn in_min(self) -> f64

Get value in minutes.

Source

pub const fn in_hours(self) -> f64

Get value in hours.

Source

pub const fn in_days(self) -> f64

Get value in days.

Source

pub const fn in_ms(self) -> f64

Get value in milliseconds.

Source

pub const fn in_us(self) -> f64

Get value in microseconds.

Source

pub const fn in_ns(self) -> f64

Get value in nanoseconds.

Source

pub const fn in_julian_years(self) -> f64

Get value in Julian years.

Source

pub fn in_unit(self, unit: TimeUnit) -> f64

Get value in the specified TimeUnit.

Source

pub fn display_as(self, unit: TimeUnit) -> DisplayWithUnit

Return a DisplayWithUnit for formatted printing in the given unit.

Source

pub fn abs(self) -> Self

Absolute value.

Source§

impl Time

Extend Time with frequency conversion.

Source

pub fn frequency(self) -> Frequency

Compute the frequency (1/t) as a Frequency.

Trait Implementations§

Source§

impl Add for Time

Source§

type Output = Time

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for Time

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
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 Debug for Time

Source§

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

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

impl Default for Time

Source§

fn default() -> Time

Returns the “default value” for a type. 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 Div<Time> for Angle

Source§

type Output = AngularVelocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> AngularVelocity

Performs the / operation. Read more
Source§

impl Div<Time> for AngularMomentum

Source§

type Output = Torque

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> Torque

Performs the / operation. Read more
Source§

impl Div<Time> for AngularVelocity

Source§

type Output = AngularAcceleration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> AngularAcceleration

Performs the / operation. Read more
Source§

impl Div<Time> for Area

Source§

type Output = SpecificAngularMomentum

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> SpecificAngularMomentum

Performs the / operation. Read more
Source§

impl Div<Time> for ElectricCharge

Source§

type Output = ElectricCurrent

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> ElectricCurrent

Performs the / operation. Read more
Source§

impl Div<Time> for Energy

Source§

type Output = Power

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> Power

Performs the / operation. Read more
Source§

impl Div<Time> for Length

Source§

type Output = Velocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> Velocity

Performs the / operation. Read more
Source§

impl Div<Time> for Mass

Source§

type Output = MassFlowRate

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> MassFlowRate

Performs the / operation. Read more
Source§

impl Div<Time> for Velocity

Source§

type Output = Acceleration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Time) -> Acceleration

Performs the / operation. Read more
Source§

impl Div<f64> for Time

Source§

type Output = Time

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self

Performs the / operation. Read more
Source§

impl Div for Time

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> f64

Performs the / operation. Read more
Source§

impl DivAssign<f64> for Time

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl Mul<Acceleration> for Time

Source§

type Output = Velocity

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Acceleration) -> Velocity

Performs the * operation. Read more
Source§

impl Mul<AngularVelocity> for Time

Source§

type Output = Angle

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: AngularVelocity) -> Angle

Performs the * operation. Read more
Source§

impl Mul<ElectricCurrent> for Time

Source§

type Output = ElectricCharge

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ElectricCurrent) -> ElectricCharge

Performs the * operation. Read more
Source§

impl Mul<Force> for Time

Source§

type Output = Impulse

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Force) -> Impulse

Performs the * operation. Read more
Source§

impl Mul<MassFlowRate> for Time

Source§

type Output = Mass

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: MassFlowRate) -> Mass

Performs the * operation. Read more
Source§

impl Mul<Time> for Acceleration

Source§

type Output = Velocity

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Velocity

Performs the * operation. Read more
Source§

impl Mul<Time> for AngularVelocity

Source§

type Output = Angle

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Angle

Performs the * operation. Read more
Source§

impl Mul<Time> for ElectricCurrent

Source§

type Output = ElectricCharge

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> ElectricCharge

Performs the * operation. Read more
Source§

impl Mul<Time> for Force

Source§

type Output = Impulse

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Impulse

Performs the * operation. Read more
Source§

impl Mul<Time> for MassFlowRate

Source§

type Output = Mass

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Mass

Performs the * operation. Read more
Source§

impl Mul<Time> for Power

Source§

type Output = Energy

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Energy

Performs the * operation. Read more
Source§

impl Mul<Time> for Torque

Source§

type Output = AngularMomentum

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> AngularMomentum

Performs the * operation. Read more
Source§

impl Mul<Time> for Velocity

Source§

type Output = Length

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Length

Performs the * operation. Read more
Source§

impl Mul<Time> for f64

Source§

type Output = Time

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Time) -> Time

Performs the * operation. Read more
Source§

impl Mul<Velocity> for Time

Source§

type Output = Length

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Velocity) -> Length

Performs the * operation. Read more
Source§

impl Mul<f64> for Time

Source§

type Output = Time

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f64> for Time

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl Neg for Time

Source§

type Output = Time

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. 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 PartialOrd for Time

Source§

fn partial_cmp(&self, other: &Time) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for Time

Source§

type Output = Time

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for Time

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Sum for Time

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Copy 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 UnsafeUnpin 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.