more naming improvements
This commit is contained in:
parent
fa450c3445
commit
9cbdd30939
@ -188,7 +188,7 @@ pub struct CdsTime<DaysLen: ProvidesDaysLength = DaysLen16Bits> {
|
|||||||
submillis: u32,
|
submillis: u32,
|
||||||
/// This is not strictly necessary but still cached because it significantly simplifies the
|
/// This is not strictly necessary but still cached because it significantly simplifies the
|
||||||
/// calculation of [`DateTime<Utc>`].
|
/// calculation of [`DateTime<Utc>`].
|
||||||
unix_stamp: UnixTime,
|
unix_time: UnixTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Common properties for all CDS time providers.
|
/// Common properties for all CDS time providers.
|
||||||
@ -641,7 +641,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
|
|||||||
if let Some(precision) = self.precision_as_ns() {
|
if let Some(precision) = self.precision_as_ns() {
|
||||||
subsec_nanos += precision;
|
subsec_nanos += precision;
|
||||||
}
|
}
|
||||||
self.unix_stamp = UnixTime::new(unix_days_seconds, subsec_nanos);
|
self.unix_time = UnixTime::new(unix_days_seconds, subsec_nanos);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn length_check(&self, buf: &[u8], len_as_bytes: usize) -> Result<(), TimestampError> {
|
fn length_check(&self, buf: &[u8], len_as_bytes: usize) -> Result<(), TimestampError> {
|
||||||
@ -668,7 +668,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
|
|||||||
pfield: Self::generate_p_field(days_len, SubmillisPrecision::Absent),
|
pfield: Self::generate_p_field(days_len, SubmillisPrecision::Absent),
|
||||||
ccsds_days,
|
ccsds_days,
|
||||||
ms_of_day,
|
ms_of_day,
|
||||||
unix_stamp: Default::default(),
|
unix_time: Default::default(),
|
||||||
submillis: 0,
|
submillis: 0,
|
||||||
};
|
};
|
||||||
let unix_days_seconds = ccsds_to_unix_days(i64::from(ccsds_days)) * SECONDS_PER_DAY as i64;
|
let unix_days_seconds = ccsds_to_unix_days(i64::from(ccsds_days)) * SECONDS_PER_DAY as i64;
|
||||||
@ -748,7 +748,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
|
|||||||
pfield: Self::generate_p_field(days_len, converter.submillis_precision()),
|
pfield: Self::generate_p_field(days_len, converter.submillis_precision()),
|
||||||
ccsds_days,
|
ccsds_days,
|
||||||
ms_of_day: converter.ms_of_day(),
|
ms_of_day: converter.ms_of_day(),
|
||||||
unix_stamp: Default::default(),
|
unix_time: Default::default(),
|
||||||
submillis: converter.submillis(),
|
submillis: converter.submillis(),
|
||||||
};
|
};
|
||||||
provider.setup(converter.unix_days_seconds(), converter.ms_of_day());
|
provider.setup(converter.unix_days_seconds(), converter.ms_of_day());
|
||||||
@ -1201,16 +1201,16 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CcsdsTimeProvider for CdsTime<Provides
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn unix_secs(&self) -> i64 {
|
fn unix_secs(&self) -> i64 {
|
||||||
self.unix_stamp.secs
|
self.unix_time.secs
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn subsec_nanos(&self) -> u32 {
|
fn subsec_nanos(&self) -> u32 {
|
||||||
self.unix_stamp.subsec_nanos
|
self.unix_time.subsec_nanos
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn unix_stamp(&self) -> UnixTime {
|
fn unix_time(&self) -> UnixTime {
|
||||||
self.unix_stamp
|
self.unix_time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1357,7 +1357,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_time_stamp_zero_args() {
|
fn test_time_stamp_zero_args() {
|
||||||
let time_stamper = CdsTime::new_with_u16_days(0, 0);
|
let time_stamper = CdsTime::new_with_u16_days(0, 0);
|
||||||
let unix_stamp = time_stamper.unix_stamp();
|
let unix_stamp = time_stamper.unix_time();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unix_stamp.secs,
|
unix_stamp.secs,
|
||||||
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32) as i64
|
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32) as i64
|
||||||
@ -1386,7 +1386,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_time_stamp_unix_epoch() {
|
fn test_time_stamp_unix_epoch() {
|
||||||
let time_stamper = CdsTime::new_with_u16_days((-DAYS_CCSDS_TO_UNIX) as u16, 0);
|
let time_stamper = CdsTime::new_with_u16_days((-DAYS_CCSDS_TO_UNIX) as u16, 0);
|
||||||
assert_eq!(time_stamper.unix_stamp().secs, 0);
|
assert_eq!(time_stamper.unix_time().secs, 0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
time_stamper.submillis_precision(),
|
time_stamper.submillis_precision(),
|
||||||
SubmillisPrecision::Absent
|
SubmillisPrecision::Absent
|
||||||
@ -1463,7 +1463,7 @@ mod tests {
|
|||||||
fn test_write() {
|
fn test_write() {
|
||||||
let mut buf = [0; 16];
|
let mut buf = [0; 16];
|
||||||
let time_stamper_0 = CdsTime::new_with_u16_days(0, 0);
|
let time_stamper_0 = CdsTime::new_with_u16_days(0, 0);
|
||||||
let unix_stamp = time_stamper_0.unix_stamp();
|
let unix_stamp = time_stamper_0.unix_time();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
unix_stamp.secs,
|
unix_stamp.secs,
|
||||||
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32).into()
|
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32).into()
|
||||||
@ -2295,7 +2295,7 @@ mod tests {
|
|||||||
fn test_update_from_now() {
|
fn test_update_from_now() {
|
||||||
let mut stamp = CdsTime::new_with_u16_days(0, 0);
|
let mut stamp = CdsTime::new_with_u16_days(0, 0);
|
||||||
let _ = stamp.update_from_now();
|
let _ = stamp.update_from_now();
|
||||||
let dt = stamp.unix_stamp().chrono_date_time().unwrap();
|
let dt = stamp.unix_time().chrono_date_time().unwrap();
|
||||||
assert!(dt.year() > 2020);
|
assert!(dt.year() > 2020);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ pub trait CcsdsTimeProvider {
|
|||||||
(self.subsec_nanos() / 1_000_000) as u16
|
(self.subsec_nanos() / 1_000_000) as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unix_stamp(&self) -> UnixTime {
|
fn unix_time(&self) -> UnixTime {
|
||||||
UnixTime::new(self.unix_secs(), self.subsec_nanos())
|
UnixTime::new(self.unix_secs(), self.subsec_nanos())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user