minor fix for UnixTimestamp
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-02-05 18:47:46 +01:00
parent 0f6595afd7
commit ac2936460f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 7 additions and 8 deletions

View File

@ -21,6 +21,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added missing Service IDs to `ecss.PusServiceId` and marked in `#[non_exhaustive]`.
## Fixed
- `time.UnixTimestamp`: All constructors and `From` conversions now use the `new` constructor,
which should cause a correct conversion of 0 subsecond milliseconds to a `None` value.
# [v0.5.2] 2023-01-26
## Added

View File

@ -285,10 +285,7 @@ impl UnixTimestamp {
pub fn from_now() -> Result<Self, SystemTimeError> {
let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?;
let epoch = now.as_secs();
Ok(UnixTimestamp {
unix_seconds: epoch as i64,
subsecond_millis: Some(now.subsec_millis() as u16),
})
Ok(Self::const_new(epoch as i64, now.subsec_millis() as u16))
}
#[inline]
@ -310,10 +307,7 @@ impl UnixTimestamp {
impl From<DateTime<Utc>> for UnixTimestamp {
fn from(value: DateTime<Utc>) -> Self {
Self {
unix_seconds: value.timestamp(),
subsecond_millis: Some(value.timestamp_subsec_millis() as u16),
}
Self::const_new(value.timestamp(), value.timestamp_subsec_millis() as u16)
}
}