Skip to main content

TimeSpan

Struct TimeSpan 

Source
#[repr(C)]
pub struct TimeSpan { pub duration: i64, }

Fields§

§duration: i64

Implementations§

Source§

impl TimeSpan

Source

pub const TICKS_PER_MICROSECOND: i64 = TICKS_PER_MICROSECOND

The number of 100-nanosecond ticks per microsecond.

Source

pub const TICKS_PER_MILLISECOND: i64 = TICKS_PER_MILLISECOND

The number of 100-nanosecond ticks per millisecond.

Source

pub const TICKS_PER_SECOND: i64 = TICKS_PER_SECOND

The number of 100-nanosecond ticks per second.

Source

pub const TICKS_PER_MINUTE: i64 = TICKS_PER_MINUTE

The number of 100-nanosecond ticks per minute.

Source

pub const TICKS_PER_HOUR: i64 = TICKS_PER_HOUR

The number of 100-nanosecond ticks per hour.

Source

pub const TICKS_PER_DAY: i64 = TICKS_PER_DAY

The number of 100-nanosecond ticks per day.

Source

pub const ZERO: TimeSpan

A zero-length TimeSpan.

Source

pub const MIN: TimeSpan

The minimum representable TimeSpan (i64::MIN ticks).

Source

pub const MAX: TimeSpan

The maximum representable TimeSpan (i64::MAX ticks).

Source

pub const fn from_ticks(ticks: i64) -> TimeSpan

Constructs a TimeSpan from a raw count of 100-nanosecond ticks.

Source

pub const fn from_micros(micros: i64) -> TimeSpan

Constructs a TimeSpan from a number of microseconds, saturating on overflow.

Source

pub const fn from_millis(millis: i64) -> TimeSpan

Constructs a TimeSpan from a number of milliseconds, saturating on overflow.

Source

pub const fn from_seconds(seconds: i64) -> TimeSpan

Constructs a TimeSpan from a number of seconds, saturating on overflow.

Source

pub const fn from_minutes(minutes: i64) -> TimeSpan

Constructs a TimeSpan from a number of minutes, saturating on overflow.

Source

pub const fn from_hours(hours: i64) -> TimeSpan

Constructs a TimeSpan from a number of hours, saturating on overflow.

Source

pub const fn from_days(days: i64) -> TimeSpan

Constructs a TimeSpan from a number of days, saturating on overflow.

Source

pub const fn ticks(self) -> i64

Returns the count of 100-nanosecond ticks in this TimeSpan.

Source

pub const fn whole_micros(self) -> i64

Returns the total number of whole microseconds in this TimeSpan.

Source

pub const fn whole_millis(self) -> i64

Returns the total number of whole milliseconds in this TimeSpan.

Source

pub const fn whole_seconds(self) -> i64

Returns the total number of whole seconds in this TimeSpan.

Source

pub const fn whole_minutes(self) -> i64

Returns the total number of whole minutes in this TimeSpan.

Source

pub const fn whole_hours(self) -> i64

Returns the total number of whole hours in this TimeSpan.

Source

pub const fn whole_days(self) -> i64

Returns the total number of whole days in this TimeSpan.

Source

pub const fn whole_nanos(self) -> i128

Returns the total duration as a count of nanoseconds.

Source

pub const fn is_zero(self) -> bool

Returns true if this TimeSpan is zero.

Source

pub const fn is_negative(self) -> bool

Returns true if this TimeSpan is negative.

Source

pub const fn is_positive(self) -> bool

Returns true if this TimeSpan is positive (strictly greater than zero).

Source

pub const fn abs(self) -> TimeSpan

Returns the absolute value of this TimeSpan, saturating at MAX when applied to MIN.

Source

pub const fn signum(self) -> i64

Returns the sign of this TimeSpan: -1, 0, or 1.

Source

pub const fn checked_add(self, rhs: TimeSpan) -> Option<TimeSpan>

Checked addition. Returns None on overflow.

Source

pub const fn checked_sub(self, rhs: TimeSpan) -> Option<TimeSpan>

Checked subtraction. Returns None on overflow.

Source

pub const fn checked_neg(self) -> Option<TimeSpan>

Checked negation. Returns None when applied to MIN.

Source

pub const fn checked_mul(self, rhs: i64) -> Option<TimeSpan>

Checked multiplication by an integer. Returns None on overflow.

Source

pub const fn checked_div(self, rhs: i64) -> Option<TimeSpan>

Checked division by an integer. Returns None if rhs is zero or on overflow.

Source

pub const fn saturating_add(self, rhs: TimeSpan) -> TimeSpan

Saturating addition.

Source

pub const fn saturating_sub(self, rhs: TimeSpan) -> TimeSpan

Saturating subtraction.

Source

pub const fn saturating_neg(self) -> TimeSpan

Saturating negation.

Trait Implementations§

Source§

impl Add for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<TimeSpan> for DateTime

Source§

type Output = DateTime

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TimeSpan) -> DateTime

Performs the + operation. Read more
Source§

impl AddAssign for TimeSpan

Source§

fn add_assign(&mut self, rhs: TimeSpan)

Performs the += operation. Read more
Source§

impl AddAssign<TimeSpan> for DateTime

Source§

fn add_assign(&mut self, rhs: TimeSpan)

Performs the += operation. Read more
Source§

impl Clone for TimeSpan

Source§

fn clone(&self) -> TimeSpan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for TimeSpan

Source§

impl Debug for TimeSpan

Source§

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

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

impl Default for TimeSpan

Source§

fn default() -> TimeSpan

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

impl Display for TimeSpan

ISO-8601 duration formatting: PnDTnHnMn.fffffffS. Negative values are prefixed with -. The ZERO value formats as PT0S.

Source§

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

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

impl Div<i64> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> TimeSpan

Performs the / operation. Read more
Source§

impl Eq for TimeSpan

Source§

impl Hash for TimeSpan

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<i64> for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> TimeSpan

Performs the * operation. Read more
Source§

impl Neg for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the - operator.
Source§

fn neg(self) -> TimeSpan

Performs the unary - operation. Read more
Source§

impl Ord for TimeSpan

Source§

fn cmp(&self, other: &TimeSpan) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for TimeSpan

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for TimeSpan

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 StructuralPartialEq for TimeSpan

Source§

impl Sub for TimeSpan

Source§

type Output = TimeSpan

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<TimeSpan> for DateTime

Source§

type Output = DateTime

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: TimeSpan) -> DateTime

Performs the - operation. Read more
Source§

impl SubAssign for TimeSpan

Source§

fn sub_assign(&mut self, rhs: TimeSpan)

Performs the -= operation. Read more
Source§

impl SubAssign<TimeSpan> for DateTime

Source§

fn sub_assign(&mut self, rhs: TimeSpan)

Performs the -= operation. Read more
Source§

impl TryFrom<Duration> for TimeSpan

Source§

type Error = TimeRangeError

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

fn try_from( value: Duration, ) -> Result<TimeSpan, <TimeSpan as TryFrom<Duration>>::Error>

Performs the conversion.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.