FIX getWeekNumbersOfMonth() drops the last week when the month ends on a Monday (#39185)

getWeekNumbersOfMonth() looped with "for ($day = 1; $day < $nb_days; ...)",
so the last day of the month was never inspected. When that last day is a
Monday it starts a new ISO week that no earlier day of the month belongs to,
so its week number was silently missing from the returned array.

This surfaces in the project "time spent per month" view
(htdocs/projet/activity/permonth.php), which builds one column per week from
this list: for such months the final week column is dropped. Over 2015-2035,
35 months are affected (e.g. 2015-08 returned weeks 31-35 but omitted 36, the
week of Monday 2015-08-31).

Fix: iterate up to and including the last day ($day <= $nb_days).

Signed-off-by: TowyTowy <towy@airreps.link>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
TowyTowy 2026-07-15 20:42:56 +02:00 committed by GitHub
parent b67c468eaf
commit acf69ceeee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1178,7 +1178,7 @@ function getWeekNumbersOfMonth($month, $year)
{
$nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$TWeek = array();
for ($day = 1; $day < $nb_days; $day++) {
for ($day = 1; $day <= $nb_days; $day++) {
$week_number = getWeekNumber($day, $month, $year);
$TWeek[$week_number] = $week_number;
}