Skip to content

Commit

Permalink
Merge pull request #418 from abreis/abs_duration
Browse files Browse the repository at this point in the history
Implement .abs() for Duration
  • Loading branch information
quodlibetor committed Jun 17, 2020
2 parents a10ced7 + ee067ba commit ce62f91
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 ce62f91

Please sign in to comment.