Skip to content

Commit 4e56fde

Browse files
committed
Implement abs() for time types
1 parent c372c04 commit 4e56fde

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/timetypes.rs

+5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ macro_rules! create_time_type {
235235
pub fn is_negative(&self) -> bool {
236236
self.intern.is_negative()
237237
}
238+
239+
/// Return the absolute value of the current time.
240+
pub fn abs(&self) -> $i {
241+
if self.is_negative() { -*self } else { *self }
242+
}
238243
}
239244

240245
impl Neg for $i {

0 commit comments

Comments
 (0)