sys/rtc_utils: correctly handle units rolling under#22357
Open
HendrikVE wants to merge 2 commits into
Open
Conversation
crasbe
reviewed
Jun 8, 2026
| .tm_hour = 12, | ||
| .tm_mday = 20, | ||
| .tm_mon = TM_MON_DEC, | ||
| .tm_year = 120 -1, |
Contributor
There was a problem hiding this comment.
Suggested change
| .tm_year = 120 -1, | |
| .tm_year = 120 - 1, |
Contributor
There was a problem hiding this comment.
Not sure though why you don't use 119 as in the tm_target above.
The tm_target below also has 120 - 1.
Contributor
Author
There was a problem hiding this comment.
I wanted to make the year roll under more explicit this way, but I can set all three to 119 if that's less confusing.
9d82482 to
2b4f91f
Compare
Contributor
|
Perhaps you can adapt the title and commit messages to fit our Commit Conventions (no "feat()" and "fix()", just "sys/rtc_utils: ...". |
Contributor
Author
Whoops :D Yes, of course. Seems like I was still in office mode using another convention. |
2b4f91f to
aa9f45c
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.
Contribution description
The existing implementation of
rtc_tm_normalizewould leave you e.g. with negative seconds if the inputtm_secwas negative. In addition, the hack of checking fort->tm_mday == 0was removed, as settingtm_mdayto0is not the correct behaviour. Since the range is given as[1 to 31]by definitiontm_mday=0must roll under to the last day of the previous month. For the same reasonrtc_localtimewas adapted to sett->tm_mday = 1;instead of using0implicitly.Testing procedure
I added relevant test cases to
tests/unittests/tests-rtc/tests-rtc.c. I checked the values fortm_targetmanually by using a calendar. Please check this part for yourself. I could have made a mistake.Issues/PRs references
None
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: