bugfix, additional test and CHANGELOG bump

This commit is contained in:
Robin Müller 2023-01-22 12:50:49 +01:00
parent 6e557c2568
commit 6eb1b1efbc
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 17 additions and 0 deletions

View File

@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Add `Ord` and `PartialOrd` implementations.
- Add `Add<Duration>` and `AddAssign<Duration>` implementations.
## Fixed
- `time::cds::TimeProvider`: Fixed a big where subsecond milliseconds were not accounted for
when the provider has no submillisecond precision.
# [v0.5.0] 2023-01-20
The timestamp of `PusTm` is now optional. See Added and Changed section for details.

View File

@ -996,8 +996,10 @@ fn add_for_max_ccsds_days_val<T: ProvidesDaysLength>(
_ => None,
}
} else {
increment_ms_of_day(&mut next_ms_of_day, duration.subsec_millis(), &mut next_ccsds_days);
None
};
// The subsecond millisecond were already handled.
let full_seconds = duration.as_secs();
let secs_of_day = (full_seconds % SECONDS_PER_DAY as u64) as u32;
let ms_of_day = secs_of_day * 1000;
@ -2102,6 +2104,16 @@ mod tests {
}
}
#[test]
fn test_addition_on_ref() {
// This test case also tests the case where there is no submillis precision but subsecond
// milliseconds.
let provider_ref = &TimeProvider::new_with_u16_days(2, 500);
let new_stamp = provider_ref + Duration::from_millis(2 * 24 * 60 * 60 * 1000 + 500);
assert_eq!(new_stamp.ccsds_days_as_u32(), 4);
assert_eq!(new_stamp.ms_of_day, 1000);
}
fn check_ps_and_carryover(prec: SubmillisPrecision, ms_of_day: u32, val: u32) {
if let SubmillisPrecision::Picoseconds(ps) = prec {
assert_eq!(ps, val);