Struct geom::Duration [−][src]
pub struct Duration(f64);
A duration, in seconds. Can be negative.
Implementations
impl Duration
[src]
impl Duration
[src]pub const ZERO: Duration
[src]
pub const EPSILON: Duration
[src]
pub fn seconds(value: f64) -> Duration
[src]
Creates a duration in seconds.
pub fn minutes(mins: usize) -> Duration
[src]
Creates a duration in minutes.
pub fn hours(hours: usize) -> Duration
[src]
Creates a duration in hours.
pub fn f64_minutes(mins: f64) -> Duration
[src]
Creates a duration in minutes.
pub const fn const_seconds(value: f64) -> Duration
[src]
pub(crate) fn to_u64(self) -> u64
[src]
pub(crate) fn from_u64(x: u64) -> Duration
[src]
pub fn abs(&self) -> Self
[src]
pub fn inner_seconds(self) -> f64
[src]
Returns the duration in seconds. Prefer working in typesafe Duration
s.
fn get_parts(self) -> (usize, usize, usize, usize)
[src]
Splits the duration into (hours, minutes, seconds, centiseconds).
pub fn parse(string: &str) -> Result<Duration>
[src]
Parses a duration such as “3:00” to Duration::minutes(3)
.
pub fn epsilon_eq(self, other: Duration) -> bool
[src]
If two durations are within this amount, they’ll print as if they’re the same.
pub fn realtime_elapsed(since: Instant) -> Duration
[src]
Returns the duration elapsed from this moment in real time.
pub fn round_up(self, multiple: Duration) -> Duration
[src]
Rounds a duration up to the nearest whole number multiple.
pub fn num_minutes_rounded_up(self) -> usize
[src]
Returns the duration as a number of minutes, rounded up.
pub fn make_intervals_for_max(
self,
num_labels: usize
) -> (Duration, Vec<Duration>)
[src]
self,
num_labels: usize
) -> (Duration, Vec<Duration>)
Returns (rounded max, the boundaries)
pub fn to_rounded_string(self, precision: usize) -> String
[src]
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");
pub fn to_string(self, fmt: &UnitFmt) -> String
[src]
Describes the duration according to formatting rules.
Trait Implementations
impl<'de> Deserialize<'de> for Duration
[src]
impl<'de> Deserialize<'de> for Duration
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl HgramValue<Duration> for Duration
[src]
impl HgramValue<Duration> for Duration
[src]impl PartialOrd<Duration> for Duration
[src]
impl PartialOrd<Duration> for Duration
[src]impl Copy for Duration
[src]
impl Eq for Duration
[src]
impl StructuralPartialEq for Duration
[src]
Auto Trait Implementations
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,