本文整理汇总了PHP中DateModules::lastJDateOfYear方法的典型用法代码示例。如果您正苦于以下问题:PHP DateModules::lastJDateOfYear方法的具体用法?PHP DateModules::lastJDateOfYear怎么用?PHP DateModules::lastJDateOfYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateModules
的用法示例。
在下文中一共展示了DateModules::lastJDateOfYear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SplitYears
function SplitYears($startDate, $endDate, $TotalAmount)
{
if (substr($startDate, 0, 1) == 2) {
$startDate = DateModules::miladi_to_shamsi($startDate);
}
if (substr($endDate, 0, 1) == 2) {
$endDate = DateModules::miladi_to_shamsi($endDate);
}
$arr = preg_split('/[\\-\\/]/', $startDate);
$StartYear = $arr[0] * 1;
$totalDays = 0;
$yearDays = array();
$newStartDate = $startDate;
while (DateModules::CompareDate($newStartDate, $endDate) < 0) {
$arr = preg_split('/[\\-\\/]/', $newStartDate);
$LastDayOfYear = DateModules::lastJDateOfYear($arr[0]);
if (DateModules::CompareDate($LastDayOfYear, $endDate) > 0) {
$LastDayOfYear = $endDate;
}
$yearDays[$StartYear] = DateModules::JDateMinusJDate($LastDayOfYear, $newStartDate) + 1;
$totalDays += $yearDays[$StartYear];
$StartYear++;
$newStartDate = DateModules::AddToJDate($LastDayOfYear, 1);
}
$TotalDays = DateModules::JDateMinusJDate($endDate, $startDate) + 1;
$sum = 0;
foreach ($yearDays as $year => $days) {
$yearDays[$year] = round($days / $TotalDays * $TotalAmount);
$sum += $yearDays[$year];
//echo $year . " " . $days . " " . $yearDays[$year] . "\n";
}
if ($sum != $TotalAmount) {
$yearDays[$year] += $TotalAmount - $sum;
}
return $yearDays;
}