From 53cf64e1c9a3fecd2b7602ba15e728f3cb704cb2 Mon Sep 17 00:00:00 2001 From: Paul Dermody Date: Mon, 25 Dec 2023 14:29:44 -0600 Subject: [PATCH] Fixed issue where last days in current and previous month produce incorrect results in timezones west of GMT. This is due to the fact that the date() function uses the local time zone to do its work which will be the day before the intended date. Note: Does dol_mktime() have a similar problem? --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 755e1d624b3..e05b74fa9a4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -315,8 +315,8 @@ if (empty($mode) || $mode == 'show_month') { $next_year = $next['year']; $next_month = $next['month']; - $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month - $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month + $max_day_in_prev_month = date("t", dol_mktime(12, 0, 0, $prev_month, 1, $prev_year, 'gmt')); // Nb of days in previous month + $max_day_in_month = date("t", dol_mktime(12, 0, 0, $month, 1, $year)); // Nb of days in next month // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, 'gmt')) + 2; // date('w') is 0 fo sunday $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);