Crate duration_breakdown[−][src]
Expand description
This crate breaks down durations of time into their constituent parts of various units (weeks, days, hours, minutes, seconds, and nanoseconds).
This can be used to convert a duration such as 10,000 seconds into the following form: 0 weeks, 0 days, 2 hours, 46 minutes, 40 seconds, and 0 nanoseconds.
Examples
use duration_breakdown::DurationBreakdown; use std::time::Duration; let breakdown = DurationBreakdown::from(Duration::new(12_345_678, 1234)); assert_eq!( breakdown.to_string(), "20 weeks, 2 days, 21 hours, 21 minutes, 18 seconds, and 1234 nanoseconds");
Structs
A DurationBreakdown
represents a duration of time that has been
broken up into several units (i.e. weeks, days, etc) in such a way
that the sum of each unit comprises the whole duration of time.
Enums
The granularity of a breakdown. A DurationBreakdown
with a Minutes
precision
would have possibly non-zero values for its weeks, days, hours, and minutes,
but 0 for its seconds and nanoseconds.