Struct irox_time::Duration

source ·
pub struct Duration { /* private fields */ }

Implementations§

source§

impl Duration

source

pub const fn new(value: f64, units: DurationUnit) -> Duration

source

pub fn value(&self) -> f64

source

pub fn units(&self) -> DurationUnit

source§

impl Duration

source

pub const fn new_seconds(value: f64) -> Duration

Creates a new duration using the specified number of seconds

source

pub fn as_ydhms(&self) -> (u64, u16, u8, u8, u8)

Returns this duration as (Years, Days, Hours, Minutes, Seconds)

source

pub fn as_dhms(&self) -> (u64, u8, u8, u8)

Returns this duration as (Days, Hours, Minutes, Seconds)

source

pub fn as_hms(&self) -> (u64, u8, u8)

Returns this duration as (Hours, Minutes, Seconds)

source

pub fn as_seconds(&self) -> u64

Returns the value of this duration as whole seconds, with any fractional element truncated off.

source

pub fn as_seconds_f64(&self) -> f64

Returns the value of this duration in fractional seconds

source

pub fn as_seconds_f32(&self) -> f32

Returns the value of this duration in fractional seconds

source

pub fn as_millis(&self) -> u64

Returns the value of this duration as whole milliseconds, with any fractional element truncated off.

source

pub fn as_micros(&self) -> u64

Returns the value of this duration as whole microseconds, with any fractional element truncated off.

source

pub fn as_nanos(&self) -> u64

Returns the value of this duration as whole microseconds, with any fractional element truncated off.

source

pub fn as_minutes(&self) -> u64

Returns the value of this duration as whole minutes, with any fractional element truncated off

source

pub fn as_hours(&self) -> u64

Returns the value of this duration as whole hours, with any fractional element truncated off

source

pub fn as_days(&self) -> u64

Returns the value of this duration as whole days, with any fractional element truncated off

source

pub fn as_years(&self) -> u64

Returns the value of this duration as whole years, with any fractional element truncated off

source§

impl Duration

source

pub const fn from_micros(micros: u64) -> Duration

Creates a new Duration from the specified number of microseconds.

Examples
use irox_units::units::duration::Duration;

let duration = Duration::from_micros(1_000_002);

assert_eq!(1, duration.as_seconds());
source

pub const fn from_millis(millis: u64) -> Duration

Creates a new Duration from the specified number of milliseconds.

Examples
use irox_units::units::duration::Duration;

let duration = Duration::from_millis(2569);

assert_eq!(2, duration.as_seconds());
source

pub const fn from_nanos(nanos: u64) -> Duration

Creates a new Duration from the specified number of nanoseconds.

Examples
use irox_units::units::duration::Duration;

let duration = Duration::from_nanos(1_000_000_123);

assert_eq!(1, duration.as_seconds());
source

pub const fn from_minutes(minutes: u64) -> Duration

source

pub const fn from_hours(hours: u64) -> Duration

source

pub const fn from_days(days: u64) -> Duration

source

pub const fn from_years(years: u64) -> Duration

source

pub const fn from_seconds(seconds: u64) -> Duration

Trait Implementations§

source§

impl Add<&&Duration> for &Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, rhs: &&Duration) -> <&Duration as Add<&&Duration>>::Output

Performs the + operation. Read more
source§

impl Add<&Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> Self::Output

Performs the + operation. Read more
source§

impl<T> Add<&Duration> for JulianDayNumber<T>

§

type Output = JulianDayNumber<T>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> Self::Output

Performs the + operation. Read more
source§

impl<T> Add<&Duration> for Timestamp<T>

§

type Output = Timestamp<T>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&Duration> for UTCDateTime

§

type Output = UTCDateTime

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> Self::Output

Performs the + operation. Read more
source§

impl Add<&mut Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

fn add(self, rhs: &mut Duration) -> Self::Output

Performs the + operation. Read more
source§

impl Add<Duration> for Date

§

type Output = Date

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> Add<Duration> for JulianDayNumber<T>

§

type Output = JulianDayNumber<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> Add<Duration> for Timestamp<T>

§

type Output = Timestamp<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Duration> for UTCDateTime

§

type Output = UTCDateTime

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add for &Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Duration) -> <&Duration as Add>::Output

Performs the + operation. Read more
source§

impl Add for Duration

§

type Output = Duration

The resulting type after applying the + operator.
source§

fn add(self, rhs: Duration) -> <Duration as Add>::Output

Performs the + operation. Read more
source§

impl AddAssign<&Duration> for Date

source§

fn add_assign(&mut self, rhs: &Duration)

Performs the += operation. Read more
source§

impl<T> AddAssign<&Duration> for JulianDayNumber<T>

source§

fn add_assign(&mut self, rhs: &Duration)

Performs the += operation. Read more
source§

impl<T> AddAssign<&Duration> for Timestamp<T>

source§

fn add_assign(&mut self, rhs: &Duration)

Performs the += operation. Read more
source§

impl AddAssign<&Duration> for UTCDateTime

source§

fn add_assign(&mut self, rhs: &Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for Date

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl<T> AddAssign<Duration> for JulianDayNumber<T>

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl<T> AddAssign<Duration> for Timestamp<T>

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign<Duration> for UTCDateTime

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl AddAssign for Duration

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl Clone for Duration

source§

fn clone(&self) -> Duration

Returns a copy 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 Duration

source§

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

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

impl Default for Duration

source§

fn default() -> Duration

Returns the “default value” for a type. Read more
source§

impl Display for Duration

source§

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

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

impl Div<f64> for Duration

§

type Output = Duration

The resulting type after applying the / operator.
source§

fn div(self, rhs: f64) -> <Duration as Div<f64>>::Output

Performs the / operation. Read more
source§

impl Div for Duration

§

type Output = f64

The resulting type after applying the / operator.
source§

fn div(self, rhs: Duration) -> <Duration as Div>::Output

Performs the / operation. Read more
source§

impl DivAssign<f64> for Duration

source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
source§

impl Format<Duration> for ISO8601Duration

source§

fn format(&self, date: &Duration) -> String

Implementation-specific format of a date or time
source§

impl From<Duration> for Duration

source§

fn from(value: Duration) -> Duration

Converts to this type from the input type.
source§

impl From<Duration> for GPSTimestamp

source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for GregorianTimestamp

source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for PrimeTimestamp

source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for UnixTimestamp

source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Duration> for WindowsNTTimestamp

source§

fn from(value: Duration) -> Self

Converts to this type from the input type.
source§

impl From<Time> for Duration

source§

fn from(value: Time) -> Self

Converts to this type from the input type.
source§

impl Mul<f64> for &Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> <&Duration as Mul<f64>>::Output

Performs the * operation. Read more
source§

impl Mul<f64> for Duration

§

type Output = Duration

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> <Duration as Mul<f64>>::Output

Performs the * operation. Read more
source§

impl MulAssign<f64> for Duration

source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
source§

impl PartialEq for Duration

source§

fn eq(&self, rhs: &Duration) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Duration

source§

fn partial_cmp(&self, rhs: &Duration) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Sub<&Duration> for JulianDayNumber<T>

§

type Output = JulianDayNumber<T>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Duration) -> Self::Output

Performs the - operation. Read more
source§

impl<T> Sub<&Duration> for Timestamp<T>

§

type Output = Timestamp<T>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Duration) -> Self::Output

Performs the - operation. Read more
source§

impl<T> Sub<Duration> for JulianDayNumber<T>

§

type Output = JulianDayNumber<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T> Sub<Duration> for Timestamp<T>

§

type Output = Timestamp<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a> Sub for &'a Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &'a Duration) -> <&'a Duration as Sub>::Output

Performs the - operation. Read more
source§

impl Sub for Duration

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Duration) -> <Duration as Sub>::Output

Performs the - operation. Read more
source§

impl<T> SubAssign<&Duration> for JulianDayNumber<T>

source§

fn sub_assign(&mut self, rhs: &Duration)

Performs the -= operation. Read more
source§

impl<T> SubAssign<&Duration> for Timestamp<T>

source§

fn sub_assign(&mut self, rhs: &Duration)

Performs the -= operation. Read more
source§

impl<T> SubAssign<Duration> for JulianDayNumber<T>

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl<T> SubAssign<Duration> for Timestamp<T>

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl SubAssign for Duration

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl Unit<DurationUnit> for Duration

source§

impl UnitStruct<DurationUnit> for Duration

source§

fn new(value: f64, units: DurationUnit) -> Duration

Creates a new type
source§

fn value(&self) -> f64

Returns the value of this struct
source§

fn units(&self) -> DurationUnit

Returns the unit type of this struct
source§

impl Copy for Duration

Auto Trait Implementations§

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> 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, U> MaybeInto<U> for T
where U: MaybeFrom<T>,

source§

fn maybe_into(self) -> Option<U>

source§

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

§

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§

default 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>,

§

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>,

§

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.