Skip to content

Commit 75d9511

Browse files
authored
AbsoluteTime: Improve API, weekly update (#19)
Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent 4b00650 commit 75d9511

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/processing/time/absolute.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
processing::TimePolynomial,
44
};
55

6-
use hifitime::{Epoch, TimeScale};
6+
use hifitime::{Epoch, TimeScale, Unit};
77

88
#[cfg(doc)]
99
use super::Timeshift;
@@ -32,20 +32,17 @@ impl GnssAbsoluteTime {
3232
}
3333
}
3434

35-
/// Discard [TimePolynomial]s that were published prior "now".
35+
/// Discard [TimePolynomial]s that were published prior proposed instant.
3636
/// You must have latched newer [TimePolynomial]s for the structure to remain valid.
37-
pub fn outdate_past(&mut self, now: Epoch) {
38-
self.polynomials.retain(|poly| poly.ref_epoch > now);
37+
pub fn outdate_past(&mut self, instant: Epoch) {
38+
self.polynomials.retain(|poly| poly.ref_epoch > instant);
3939
}
4040

41-
/// Discard [TimePolynomial]s that were published during past week from "now".
41+
/// Discard [TimePolynomial]s that were published 7 days prior the proposed instant.
4242
/// You must have latched newer [TimePolynomial]s for the structure to remain valid.
43-
pub fn outdate_weekly(&mut self, now: Epoch) {
44-
let new_week = now.to_time_of_week().0;
45-
self.polynomials.retain(|poly| {
46-
let tow = poly.ref_epoch.to_time_of_week().0;
47-
tow >= new_week
48-
});
43+
pub fn outdate_weekly(&mut self, instant: Epoch) {
44+
let limit = instant - 7.0 * Unit::Week;
45+
self.polynomials.retain(|poly| poly.ref_epoch > limit);
4946
}
5047

5148
/// [Epoch] interpolation & correction attempt, into desired [TimeScale].

0 commit comments

Comments
 (0)