Skip to content

Commit 3d7face

Browse files
committed
Rebase, cargo fmt, and review feedback
1 parent 908acb0 commit 3d7face

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

src/components/datetime.rs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,10 @@ mod tests {
543543
use crate::{
544544
components::{calendar::Calendar, duration::DateDuration, Duration},
545545
iso::{IsoDate, IsoTime},
546-
options::{DifferenceSettings, RoundingIncrement, RoundingOptions, TemporalRoundingMode, TemporalUnit},
546+
options::{
547+
DifferenceSettings, RoundingIncrement, RoundingOptions, TemporalRoundingMode,
548+
TemporalUnit,
549+
},
547550
primitive::FiniteF64,
548551
};
549552

@@ -744,33 +747,45 @@ mod tests {
744747
assert_eq!(dt.nanosecond(), expected.8);
745748
};
746749

747-
let gen_rounding_options = | smallest: TemporalUnit, increment: u32 | -> RoundingOptions {
750+
let gen_rounding_options = |smallest: TemporalUnit, increment: u32| -> RoundingOptions {
748751
RoundingOptions {
749752
largest_unit: None,
750753
smallest_unit: Some(smallest),
751754
increment: Some(RoundingIncrement::try_new(increment).unwrap()),
752755
rounding_mode: None,
753756
}
754-
755757
};
756-
let dt = DateTime::new(1976, 11, 18, 14, 23, 30, 123, 456, 789, Calendar::default()).unwrap();
758+
let dt =
759+
DateTime::new(1976, 11, 18, 14, 23, 30, 123, 456, 789, Calendar::default()).unwrap();
757760

758-
let result = dt.round(gen_rounding_options(TemporalUnit::Hour, 4)).unwrap();
761+
let result = dt
762+
.round(gen_rounding_options(TemporalUnit::Hour, 4))
763+
.unwrap();
759764
assert_datetime(result, (1976, 11, 18, 16, 0, 0, 0, 0, 0));
760765

761-
let result = dt.round(gen_rounding_options(TemporalUnit::Minute, 15)).unwrap();
766+
let result = dt
767+
.round(gen_rounding_options(TemporalUnit::Minute, 15))
768+
.unwrap();
762769
assert_datetime(result, (1976, 11, 18, 14, 30, 0, 0, 0, 0));
763-
764-
let result = dt.round(gen_rounding_options(TemporalUnit::Second, 30)).unwrap();
770+
771+
let result = dt
772+
.round(gen_rounding_options(TemporalUnit::Second, 30))
773+
.unwrap();
765774
assert_datetime(result, (1976, 11, 18, 14, 23, 30, 0, 0, 0));
766-
767-
let result = dt.round(gen_rounding_options(TemporalUnit::Millisecond, 10)).unwrap();
775+
776+
let result = dt
777+
.round(gen_rounding_options(TemporalUnit::Millisecond, 10))
778+
.unwrap();
768779
assert_datetime(result, (1976, 11, 18, 14, 23, 30, 120, 0, 0));
769-
770-
let result = dt.round(gen_rounding_options(TemporalUnit::Microsecond, 10)).unwrap();
780+
781+
let result = dt
782+
.round(gen_rounding_options(TemporalUnit::Microsecond, 10))
783+
.unwrap();
771784
assert_datetime(result, (1976, 11, 18, 14, 23, 30, 123, 460, 0));
772-
773-
let result = dt.round(gen_rounding_options(TemporalUnit::Nanosecond, 10)).unwrap();
785+
786+
let result = dt
787+
.round(gen_rounding_options(TemporalUnit::Nanosecond, 10))
788+
.unwrap();
774789
assert_datetime(result, (1976, 11, 18, 14, 23, 30, 123, 456, 790));
775790
}
776791
}

src/iso.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ impl IsoDateTime {
175175

176176
pub(crate) fn round(&self, resolved_options: ResolvedRoundingOptions) -> TemporalResult<Self> {
177177
let (rounded_days, rounded_time) = self.time.round(resolved_options)?;
178-
let balance_result = IsoDate::balance(self.date.year, self.date.month.into(), i32::from(self.date.day) + rounded_days);
178+
let balance_result = IsoDate::balance(
179+
self.date.year,
180+
self.date.month.into(),
181+
i32::from(self.date.day) + rounded_days,
182+
);
179183
Self::new(balance_result, rounded_time)
180184
}
181185

@@ -724,7 +728,7 @@ impl IsoTime {
724728
}
725729
_ => {
726730
return Err(TemporalError::range()
727-
.with_message("Invalid smallestUNit value for time rounding."))
731+
.with_message("Invalid smallestUnit value for time rounding."))
728732
}
729733
};
730734
// 7. Let unitLength be the value in the "Length in Nanoseconds" column of the row of Table 22 whose "Singular" column contains unit.

0 commit comments

Comments
 (0)