Struct time::Duration

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

ISO 8601 time duration with nanosecond precision. This also allows for the negative duration; see individual methods for details.

Implementations§

Makes a new Duration with given number of weeks. Equivalent to Duration::seconds(weeks * 7 * 24 * 60 * 60) with overflow checks. Panics when the duration is out of bounds.

Makes a new Duration with given number of days. Equivalent to Duration::seconds(days * 24 * 60 * 60) with overflow checks. Panics when the duration is out of bounds.

Makes a new Duration with given number of hours. Equivalent to Duration::seconds(hours * 60 * 60) with overflow checks. Panics when the duration is out of bounds.

Makes a new Duration with given number of minutes. Equivalent to Duration::seconds(minutes * 60) with overflow checks. Panics when the duration is out of bounds.

Makes a new Duration with given number of seconds. Panics when the duration is more than i64::MAX milliseconds or less than i64::MIN milliseconds.

Makes a new Duration with given number of milliseconds.

Makes a new Duration with given number of microseconds.

Makes a new Duration with given number of nanoseconds.

Runs a closure, returning the duration of time it took to run the closure.

Returns the total number of whole weeks in the duration.

Returns the total number of whole days in the duration.

Returns the total number of whole hours in the duration.

Returns the total number of whole minutes in the duration.

Returns the total number of whole seconds in the duration.

Returns the total number of whole milliseconds in the duration,

Returns the total number of whole microseconds in the duration, or None on overflow (exceeding 263 microseconds in either direction).

Returns the total number of whole nanoseconds in the duration, or None on overflow (exceeding 263 nanoseconds in either direction).

Add two durations, returning None if overflow occurred.

Subtract two durations, returning None if overflow occurred.

The minimum possible Duration: i64::MIN milliseconds.

The maximum possible Duration: i64::MAX milliseconds.

A duration where the stored seconds and nanoseconds are equal to zero.

Returns true if the duration equals Duration::zero().

Creates a time::Duration object from std::time::Duration

This function errors when original duration is larger than the maximum value supported for this type.

Creates a std::time::Duration object from time::Duration

This function errors when duration is less than zero. As standard library implementation is limited to non-negative values.

Trait Implementations§

The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more
The resulting type after applying the + operator.
Performs the + operation. Read more

The resulting Tm is in UTC.

The resulting type after applying the + operator.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the - operator.
Performs the unary - operation. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more

The resulting Tm is in UTC.

The resulting type after applying the - operator.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.