-
Notifications
You must be signed in to change notification settings - Fork 9
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
Change conversion of NTP64 and Timestamp to/from String #16
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mallets
reviewed
Jul 3, 2024
Mallets
reviewed
Jul 3, 2024
Mallets
reviewed
Jul 3, 2024
Mallets
reviewed
Jul 3, 2024
Mallets
reviewed
Jul 3, 2024
Mallets
approved these changes
Jul 3, 2024
JEnoch
changed the title
Change conversion of NTP64 and Timesamp to/from String
Change conversion of NTP64 and Timestamp to/from String
Jul 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #15 in
0.7.0
and previous versions the formatting and conversion ofNTP64
andTimestamp
into a String uses the RFC3339 representation, suffering of rounding and thus loss of precision when converting the fraction of seconds part into nanoseconds.The consequence was that conversion from/to String was not bijective (i.e. you might not get back the original value after a 2-ways conversion).
This PR changes the default conversion of
NTP64
andTimestamp
into a String, formatting the time as an unsigned integer in decimal format. This conversion is lossless and bijective.For conversion to RFC3339 format, those methods are added:
NTP64::to_string_rfc3339_lossy()
NTP64::parse_rfc3339()
println!("{:#}", my_ntp64);
)Timestamp::to_string_rfc3339_lossy()
Timestamp::parse_rfc3339()
println!("{:#}", my_timestamp);
)Note that those new methods are not available in
no_std
context.Closes #15