Expand description
Wall-clock conversion, parsing, and duration-formatting utilities.
The helpers convert between SystemTime and the Unix epoch, parse
human-readable durations, and choose display units. These clocks are not
monotonic and can be affected by system-time changes.
Re-exportsยง
use std::time::Duration;๐use std::time::SystemTime;๐use std::time::UNIX_EPOCH;๐pub use elapsed::Elapsed;use crate::Result;๐use crate::err;๐
Modulesยง
- elapsed ๐
- exponential_
backoff - Retry-backoff calculations.
Enumsยง
- Unit
- Represents an integral duration in one selected unit.
Functionsยง
- deadline_
has_ passed - Checks whether an optional deadline has passed.
- duration_
since_ epoch - Converts a system time into a nonnegative duration since the Unix epoch.
- format
- Formats a system time in UTC with a Chrono format string.
- millis
- Converts a duration to whole milliseconds when they fit in a
u64. - now
- Returns the current wall-clock duration since the Unix epoch.
- now_
millis - Returns the current wall-clock time as whole milliseconds since the Unix epoch.
- now_
secs - Returns the current wall-clock time as whole seconds since the Unix epoch.
- parse_
duration - Parses a human-readable duration with the
cyborgtimeparser. - parse_
timepoint_ ago - Parses a duration and returns the wall-clock time that far in the past.
- pretty
- Formats a duration with one plural human-readable unit.
- rfc2822_
from_ seconds - Formats a signed Unix timestamp as RFC 2822 text in UTC.
- timepoint_
ago - Subtracts a duration from the current wall-clock time using checked arithmetic.
- timepoint_
from_ epoch - Adds a duration to the Unix epoch using checked arithmetic.
- timepoint_
from_ now - Adds a duration to the current wall-clock time using checked arithmetic.
- timepoint_
has_ passed - Checks whether a system time is at or before the current wall-clock time.
- whole_
and_ frac - Pairs a durationโs selected whole unit with its fraction in
[0, 1). - whole_
unit - Selects the largest integral unit represented by a duration.