feat: optimize compatibility for PHP without the "--enable-calendar" option, #66

This commit is contained in:
Emil Zhai
2022-11-30 06:50:05 +00:00
parent 9f8876a9fc
commit e33a5cf0b4

View File

@@ -41,7 +41,7 @@ class Access_Statistic {
if(!preg_match('/^\d{4}-\d{2}$/', $dstTime))
throw new Exception('Bad Request', 400);
[$year, $month] = explode('-', $dstTime);
$monthDays = cal_days_in_month(CAL_GREGORIAN, intval($month), intval($year)); # 计算当月天数
$monthDays = date('t', mktime(0, 0, 0, intval($month), 1, intval($year))); # 计算当月天数
$startTime = strtotime(date("{$dstTime}-01 00:00:00"));
$endTime = strtotime(date("{$dstTime}-{$monthDays} 23:59:59"));
break;
@@ -193,7 +193,7 @@ class Access_Statistic {
throw new Exception('Bad Request', 400);
[$year, $month] = explode('-', $dstTime);
$loopStart = 1;
$loopEnd = cal_days_in_month(CAL_GREGORIAN, intval($month), intval($year)); # 计算当月天数
$loopEnd = date('t', mktime(0, 0, 0, intval($month), 1, intval($year))); # 计算当月天数
break;
default:
throw new Exception('Bad Request', 400);