Skip to content

Commit

Permalink
Add the abs() methods to Duration
Browse files Browse the repository at this point in the history
  • Loading branch information
abreis committed Jun 16, 2020
1 parent 614ec87 commit ee067ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/oldtime.rs
Expand Up @@ -229,6 +229,12 @@ impl Duration {
if d < MIN || d > MAX { None } else { Some(d) }
}

/// Returns the duration as an absolute (non-negative) value.
#[inline]
pub fn abs(&self) -> Duration {
Duration { secs: self.secs.abs(), nanos: self.nanos }
}

/// The minimum possible `Duration`: `i64::MIN` milliseconds.
#[inline]
pub fn min_value() -> Duration { MIN }
Expand Down

0 comments on commit ee067ba

Please sign in to comment.