Repository navigation
Fix fractional seconds for sys_time with custom periods - #5034
vera-rubin wants to merge 2 commits into
Conversation
|
For some reason, GitHub Actions hasn't been triggered. Closing and reopening the PR as a workaround. |
vitaut
left a comment
There was a problem hiding this comment.
Please rebase to fix CI fuzz signal.
Keep the subsecond remainder of a sys_time in the common duration type instead of casting it back to Duration, which truncates it when one second is not a whole number of Duration ticks, e.g. a 3/2 s period.
3b0ed16 to
2387a5c
Compare
|
Rebased on main, which has the CIFuzz update; the change itself is the same single commit. |
| auto second = | ||
| detail::duration_cast<decltype(subsecs)>(std::chrono::seconds(1)); |
There was a problem hiding this comment.
The explicit duration cast seems unnecessary.
Drop the explicit duration cast: std::chrono::seconds converts implicitly to the common duration type of the subsecond remainder.
|
Removed the explicit cast, thanks: |
|
For some reason, GitHub Actions doesn't get triggered by your pushes, but closing and reopening the PR does trigger CI. There might be an account-specific restriction on GitHub's side. Could you contact GitHub Support to investigate? |
|
Thanks for re-running it. I see the same thing on my PRs in other repos since about Nov 23: my own pushes and new PRs create no Actions runs at all, while a maintainer's close/reopen does. So it looks account-side, and I've opened a ticket with GitHub Support. |
A
sys_timewhose period is not a divisor of one second loses its fractional seconds:The remainder
epoch - duration_cast<seconds>(epoch)is half a second here, but it is cast back toDuration(3/2 s ticks), which truncates it to zero. This keeps it in the common duration type, as thelocal_timeformatter already does since 4ded41f.utc_timegoes through the same code.The new test fails on main and passes with the change. The full test suite passes (Release, C++20), and chrono-test also passes when built as C++11 and C++17.