Struct time::Duration [-] [+] [src]

pub struct Duration {
    // some fields omitted
}

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

Methods

impl Duration

fn weeks(weeks: i64) -> Duration

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.

fn days(days: i64) -> Duration

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.

fn hours(hours: i64) -> Duration

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.

fn minutes(minutes: i64) -> Duration

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.

fn seconds(seconds: i64) -> Duration

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.

fn milliseconds(milliseconds: i64) -> Duration

Makes a new Duration with given number of milliseconds.

fn microseconds(microseconds: i64) -> Duration

Makes a new Duration with given number of microseconds.

fn nanoseconds(nanos: i64) -> Duration

Makes a new Duration with given number of nanoseconds.

fn span<F>(f: F) -> Duration where F: FnOnce()

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

fn num_weeks(&self) -> i64

Returns the total number of whole weeks in the duration.

fn num_days(&self) -> i64

Returns the total number of whole days in the duration.

fn num_hours(&self) -> i64

Returns the total number of whole hours in the duration.

fn num_minutes(&self) -> i64

Returns the total number of whole minutes in the duration.

fn num_seconds(&self) -> i64

Returns the total number of whole seconds in the duration.

fn num_milliseconds(&self) -> i64

Returns the total number of whole milliseconds in the duration,

fn num_microseconds(&self) -> Option<i64>

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

fn num_nanoseconds(&self) -> Option<i64>

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

fn checked_add(&self, rhs: &Duration) -> Option<Duration>

Add two durations, returning None if overflow occurred.

fn checked_sub(&self, rhs: &Duration) -> Option<Duration>

Subtract two durations, returning None if overflow occurred.

fn min_value() -> Duration

The minimum possible Duration: i64::MIN milliseconds.

fn max_value() -> Duration

The maximum possible Duration: i64::MAX milliseconds.

fn zero() -> Duration

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

fn is_zero(&self) -> bool

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

Trait Implementations

impl Neg for Duration

type Output = Duration

fn neg(self) -> Duration

impl Add for Duration

type Output = Duration

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

impl Sub for Duration

type Output = Duration

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

impl Mul<i32> for Duration

type Output = Duration

fn mul(self, rhs: i32) -> Duration

impl Div<i32> for Duration

type Output = Duration

fn div(self, rhs: i32) -> Duration

impl Display for Duration

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

Derived Implementations

impl Debug for Duration

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Ord for Duration

fn cmp(&self, __arg_0: &Duration) -> Ordering

impl PartialOrd for Duration

fn partial_cmp(&self, __arg_0: &Duration) -> Option<Ordering>

fn lt(&self, __arg_0: &Duration) -> bool

fn le(&self, __arg_0: &Duration) -> bool

fn gt(&self, __arg_0: &Duration) -> bool

fn ge(&self, __arg_0: &Duration) -> bool

impl Eq for Duration

impl PartialEq for Duration

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

fn ne(&self, __arg_0: &Duration) -> bool

impl Copy for Duration

impl Clone for Duration

fn clone(&self) -> Duration

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