Skip to content

Conversation

jbangelo
Copy link
Collaborator

@jbangelo jbangelo commented Aug 26, 2025

The next chunk of changes from #122.

This re-implements the time related functionality in native Rust. This one is a bit larger, mostly from the fact that the conversions in the C implementation are very inter-dependent and so several new bits of functionality were pulled in to make the Rust implementation mirror the C implementation. There's a few bits of functionality thrown out because they caused some significant unsoundness, but I'm sure there is still several bits of unsoundness in this translation (e.g. several panics/asserts are still present). I'd prefer to keep this PR as close to a straight translation as possible, and re-consider the soundness concerns in a future PR.

What's been changed

  • I don't think any implementations are still present but meaningfully modified

What's been removed

  • GloTime - GLONASS time is particularly complicated and rarely used
  • GpsTime::to_glo() and GpsTime::to_glo_hardcoded() - See above
  • impl Sub<GpsTime> for GpsTime - It turns out a std::time::Duration can't hold a negative value. This implementation would occasionally panic because of this. The chrono crate handles this better, maybe we can move towards their approach in a later PR?
  • UtcParams::decode() - Decoding low-level messages seem unlikely to be needed
  • impl Default for UtcParams - Defaulting this data can cause unexpected errors
  • impl Default for UtcTime - Defaulting this type can cause unexpected errors

What's been added

  • The time::consts module
  • GpsTime::from_date() and GpsTime::from_date_hardcoded()
  • GpsTime::to_mjd() and GpsTime::to_mjd_hardcoded()
  • GpsTime::to_date() and GpsTime::to_date_hardcoded()
  • UtcTime::to_date()
  • MJD::to_gps() and MJD::to_gps_hardcoded()
  • MJD::to_date()

@jbangelo jbangelo force-pushed the jbangelo/riir-time branch from d1b6701 to e1acb6f Compare August 26, 2025 04:06
@jbangelo jbangelo force-pushed the jbangelo/riir-time branch from e1acb6f to 3caed50 Compare August 26, 2025 04:44
@jbangelo jbangelo marked this pull request as ready for review August 26, 2025 04:49
@jbangelo jbangelo requested a review from a team as a code owner August 26, 2025 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant