Skip to main content

Module time

Module time 

1.25.0 · Source
Expand description

Temporal quantification.

§Examples:

There are multiple ways to create a new Duration:

let five_seconds = Duration::from_secs(5);
assert_eq!(five_seconds, Duration::from_millis(5_000));
assert_eq!(five_seconds, Duration::from_micros(5_000_000));
assert_eq!(five_seconds, Duration::from_nanos(5_000_000_000));

let ten_seconds = Duration::from_secs(10);
let seven_nanos = Duration::from_nanos(7);
let total = ten_seconds + seven_nanos;
assert_eq!(total, Duration::new(10, 7));

Re-exports§

use crate::fmt; 🔒
use crate::iter::Sum; 🔒
use crate::num::niche_types::Nanoseconds; 🔒 Experimental
use crate::ops::Add; 🔒
use crate::ops::AddAssign; 🔒
use crate::ops::Div; 🔒
use crate::ops::DivAssign; 🔒
use crate::ops::Mul; 🔒
use crate::ops::MulAssign; 🔒
use crate::ops::Sub; 🔒
use crate::ops::SubAssign; 🔒

Macros§

sum_durations 🔒
try_from_secs 🔒

Structs§

Duration
A Duration type to represent a span of time, typically used for system timeouts.
TryFromFloatSecsError
An error which can be returned when converting a floating-point value of seconds into a Duration.
DisplaySecondsExperimental
Displays Duration in seconds, even if it only contains the nanosecond part.

Enums§

TryFromFloatSecsErrorKind 🔒

Constants§

MICROS_PER_SEC 🔒
MILLIS_PER_SEC 🔒
NANOS_PER_MICRO 🔒
NANOS_PER_MILLI 🔒
NANOS_PER_SEC 🔒
DAYS_PER_WEEK 🔒 Experimental
HOURS_PER_DAY 🔒 Experimental
MINS_PER_HOUR 🔒 Experimental
SECS_PER_MINUTE 🔒 Experimental

Functions§

fmt_decimal 🔒
Formats a floating point number in decimal notation.