From 74ec7aa5b2065718e89ea69a3d7c2eb175bc720d Mon Sep 17 00:00:00 2001 From: David Kellum Date: Sun, 4 Mar 2018 18:27:36 -0800 Subject: [PATCH] Improve up/down variable naming --- src/round.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/round.rs b/src/round.rs index 22b0132..fc9ff1d 100644 --- a/src/round.rs +++ b/src/round.rs @@ -27,13 +27,13 @@ where T: Timelike + Add + Sub { fn round(self, digits: u16) -> T { let span = span_for_digits(digits); - let rem = self.nanosecond() % span; - if rem > 0 { - let rev = span - rem; - if rev <= rem { - self + Duration::nanoseconds(rev.into()) // up + let delta_down = self.nanosecond() % span; + if delta_down > 0 { + let delta_up = span - delta_down; + if delta_up <= delta_down { + self + Duration::nanoseconds(delta_up.into()) } else { - self - Duration::nanoseconds(rem.into()) // down + self - Duration::nanoseconds(delta_down.into()) } } else { self // unchanged @@ -42,9 +42,9 @@ where T: Timelike + Add + Sub fn trunc(self, digits: u16) -> T { let span = span_for_digits(digits); - let rem = self.nanosecond() % span; - if rem > 0 { - self - Duration::nanoseconds(rem.into()) // truncate + let delta_down = self.nanosecond() % span; + if delta_down > 0 { + self - Duration::nanoseconds(delta_down.into()) } else { self // unchanged }