From bc9ca28deb98b7eaee38f874e7cf0448c5ec6cc1 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Fri, 13 Oct 2023 23:41:08 -0700 Subject: [PATCH] Use DateTime::format Rather than cal_days_in_month in Sample (#3764) Fix #3760. That problem actually was easily fixed, by enabling calendar extension in user's environment. Astonishingly, however, this is the only use of calendar in the entire project. Since the same functionality is available in DateTime, which is used throughout the project, use that instead to eliminate the dependency on calendar. --- samples/Chart/33_Chart_create_line_dateaxis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Chart/33_Chart_create_line_dateaxis.php b/samples/Chart/33_Chart_create_line_dateaxis.php index e5296d1de..d7b674f6d 100644 --- a/samples/Chart/33_Chart_create_line_dateaxis.php +++ b/samples/Chart/33_Chart_create_line_dateaxis.php @@ -361,8 +361,8 @@ function dateRange(int $nrows, Spreadsheet $wrkbk): array $lastYr = (int) $lastDate->format('Y'); $qtr = intdiv($lastMonth, 3) + (($lastMonth % 3 > 0) ? 1 : 0); $qtrEndMonth = 3 + (($qtr - 1) * 3); - $lastDOM = cal_days_in_month(CAL_GREGORIAN, $qtrEndMonth, $lastYr); $qtrEndMonth = sprintf('%02d', $qtrEndMonth); + $lastDOM = DateTime::createFromFormat('Y-m-d', "$lastYr-$qtrEndMonth-01")->format('t'); $qtrEndStr = "$lastYr-$qtrEndMonth-$lastDOM"; $ExcelQtrEndDateVal = SharedDate::convertIsoDate($qtrEndStr);