Improve up/down variable naming

This commit is contained in:
David Kellum 2018-03-04 18:27:36 -08:00
parent b5acb0ed95
commit 74ec7aa5b2
1 changed files with 9 additions and 9 deletions

View File

@ -27,13 +27,13 @@ where T: Timelike + Add<Duration, Output=T> + Sub<Duration, Output=T>
{ {
fn round(self, digits: u16) -> T { fn round(self, digits: u16) -> T {
let span = span_for_digits(digits); let span = span_for_digits(digits);
let rem = self.nanosecond() % span; let delta_down = self.nanosecond() % span;
if rem > 0 { if delta_down > 0 {
let rev = span - rem; let delta_up = span - delta_down;
if rev <= rem { if delta_up <= delta_down {
self + Duration::nanoseconds(rev.into()) // up self + Duration::nanoseconds(delta_up.into())
} else { } else {
self - Duration::nanoseconds(rem.into()) // down self - Duration::nanoseconds(delta_down.into())
} }
} else { } else {
self // unchanged self // unchanged
@ -42,9 +42,9 @@ where T: Timelike + Add<Duration, Output=T> + Sub<Duration, Output=T>
fn trunc(self, digits: u16) -> T { fn trunc(self, digits: u16) -> T {
let span = span_for_digits(digits); let span = span_for_digits(digits);
let rem = self.nanosecond() % span; let delta_down = self.nanosecond() % span;
if rem > 0 { if delta_down > 0 {
self - Duration::nanoseconds(rem.into()) // truncate self - Duration::nanoseconds(delta_down.into())
} else { } else {
self // unchanged self // unchanged
} }