当前位置: 首页>>代码示例>>PHP>>正文


PHP DateModules::lastJDateOfYear方法代码示例

本文整理汇总了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;
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:36,代码来源:compute.inc.php


注:本文中的DateModules::lastJDateOfYear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。