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.
This commit is contained in:
oleibman
2023-10-13 23:41:08 -07:00
committed by GitHub
parent db35a4127d
commit bc9ca28deb
@@ -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);