Struct geom::duration::Duration [−][src]
pub struct Duration(f64);
Expand description
A duration, in seconds. Can be negative.
Tuple Fields
0: f64
Implementations
Creates a duration in minutes.
Creates a duration in milliseconds.
Returns the duration in seconds. Prefer working in typesafe Duration
s.
Splits the duration into (hours, minutes, seconds, deciseconds).
Parses a duration such as “3:00” to Duration::minutes(3)
.
If two durations are within this amount, they’ll print as if they’re the same.
Returns the duration elapsed from this moment in real time.
Rounds a duration up to the nearest whole number multiple.
Returns the duration as a number of minutes, rounded up.
Returns (rounded max, the boundaries)
Shows only the largest unit (hours, minute, seconds), rounded to precision
decimal points.
use geom::Duration;
assert_eq!(Duration::seconds(3600.0).to_rounded_string(0), "1hr");
assert_eq!(Duration::seconds(3600.0).to_rounded_string(1), "1.0hr");
assert_eq!(Duration::seconds(7800.0).to_rounded_string(0), "2hr");
assert_eq!(Duration::seconds(800.0).to_rounded_string(1), "13.3min");
assert_eq!(Duration::seconds(-800.0).to_rounded_string(1), "-13.3min");
assert_eq!(Duration::seconds(0.0).to_rounded_string(0), "0");
assert_eq!(Duration::seconds(12.5).to_rounded_string(1), "12.5s");
assert_eq!(Duration::seconds(12.5).to_rounded_string(2), "12.50s");
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Duration
impl UnwindSafe for Duration
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self