feat: avoid using months when displaying certificate duration#3673
Merged
reubenmiller merged 1 commit intothin-edge:mainfrom Jun 6, 2025
Merged
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Contributor
Robot Results
|
albinsuresh
approved these changes
Jun 6, 2025
didier-wenzek
approved these changes
Jun 6, 2025
Contributor
didier-wenzek
left a comment
There was a problem hiding this comment.
I confirm my approval after the fixup to show total years as well (i.e. 5y 219d instead of 2044d)
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
4acd600 to
6741084
Compare
This file contains hidden or 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
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.
Proposed changes
Improve the certificate validity duration by only using years, days, hours, minutes and seconds (avoiding months), to align to user expectations and avoid the "days in a month" rounding errors in the total duration.
Some examples of the duration in the new format:
Background
The humantime crate uses averaged units in the conversion to a human time, so for a duration spanning months, then the remaining hours part of the duration can get skewed unexpectedly (from the users perspective).
For instance, when a certificate is renewed using the Cumulocity Certificate Authority, the new certificate has a validity of 1 year (~365 days if you ignore leap years etc.). When the user downloads a new certificate from Cumulocity, the validity of the certificate is set to 1 year, however the duration displayed is:
Where the number of hours remaining is unexpected, as something like
23h 48m 54swould of been more expected (assuming we ignore leap years, total days in a month etc.).The displaying of the duration in months has the potential to raise more questions, and to avoid having to explain it every time, I'd propose to change to using days as the maximum unit of measurement.
Before (current)
After
Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments