Repository navigation
Fix age(week, ...) being off by one week - #122633
Conversation
|
Workflow [PR], commit [e9a1794] Summary: ✅
AI ReviewSummaryThis PR fixes the two broken correction paths in Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit e9a1794.
Changed lines: Changed C/C++ lines covered: 12/12 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline. |
diegomestre2
left a comment
There was a problem hiding this comment.
The logic looks good but there is a comparison chain that is a bit complex to follow and bound to error, maybe the std::tie could help simplifying it.
diegomestre2
left a comment
There was a problem hiding this comment.
Good to be merged, it fixes the issue and adds the necessary tests to check for correct output.
Closes: #122630
Closes: #63812
Closes: #68345
age('week', start, end)counts the Mondays betweenstartandend, then subtracts 1 ifstartis later in its week thanend(weekday first, time only if the weekdays are equal). That second step had two bugs.1. The time was compared even when the weekdays differ (misplaced brackets):
Monday is before Thursday, but the hours are equal and 10 minutes > 0 minutes, so a week was subtracted.
2. The weekdays were not swapped for reversed arguments. When
startis later thanend, the code swaps the two values but not their weekdays. This affects dates too:age('week', toDate('2024-01-10'), toDate('2024-01-01'))returned0instead of-1, and02477_age.referencehad-103instead of-104.The fix compares the time only for equal weekdays, and swaps the weekdays with the values.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
age('week', ...)sometimes being off by one week when the dates fall on different weekdays.Workflow [PR]
Sync PR [sync-upstream/pr/122633]
Version info
26.10.1.911-master(included in26.10and later)