mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-30 03:59:11 +00:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user