-
-
Notifications
You must be signed in to change notification settings - Fork 31
Add Epoch::from_ptp_* #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the PR! Could you also add a from_ptp_duration constructor, similar to https://docs.rs/hifitime/latest/hifitime/struct.Epoch.html#method.from_tai_duration. Thanks |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #379 +/- ##
==========================================
- Coverage 84.32% 83.87% -0.46%
==========================================
Files 23 24 +1
Lines 3720 3813 +93
==========================================
+ Hits 3137 3198 +61
- Misses 583 615 +32 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hmm, I can tackle the dependency error. It seems like the MSRV may need updating again. |
src/epoch/initializers.rs
Outdated
| #[must_use] | ||
| /// Initialize an Epoch from the provided IEEE 1588-2008 (PTPv2) millisecond timestamp since TAI midnight 1970 January 01. | ||
| /// PTP uses the TAI timescale but with the Unix Epoch for compatibility with unix systems. | ||
| pub fn from_ptp_milliseconds(millisecond: f64) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thought,
(I also like having construction methods like these a lot, they make life much easier for the end user)
but since PTP applications are usually located around tens of nanoseconds, I would rather have from_ptp_nanoseconds instead of milliseconds ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point. added
Yeah not too sure what to do about that. |
|
Thanks @georgeboot , I'll merge this now. I'm working on fixing the lints on another branch. It'll be released with version 4.1.0 in the coming days. |
This pull requests adds the
Epoch::from_ptp_secondsandEpoch::from_ptp_millisecondshelper methods to deal with IEEE 1588-2008 time being in TAI but using the unix reference epoch.I'm not 100% happpy with the naming of the methods however. By default IEEE 1588-2008 uses TAI with unix epoch, but the standard does not enforce this. In practice, (practically) all implementations use it however.
Fixes #378