當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTime::isLeapYear方法代碼示例

本文整理匯總了PHP中DateTime::isLeapYear方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTime::isLeapYear方法的具體用法?PHP DateTime::isLeapYear怎麽用?PHP DateTime::isLeapYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateTime的用法示例。


在下文中一共展示了DateTime::isLeapYear方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: AMORLINC

 /**
  * AMORLINC
  *
  * Returns the depreciation for each accounting period.
  * This function is provided for the French accounting system. If an asset is purchased in
  * the middle of the accounting period, the prorated depreciation is taken into account.
  *
  * Excel Function:
  *        AMORLINC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
  *
  * @access    public
  * @category Financial Functions
  * @param    float    cost        The cost of the asset.
  * @param    mixed    purchased    Date of the purchase of the asset.
  * @param    mixed    firstPeriod    Date of the end of the first period.
  * @param    mixed    salvage        The salvage value at the end of the life of the asset.
  * @param    float    period        The period.
  * @param    float    rate        Rate of depreciation.
  * @param    integer    basis        The type of day count to use.
  *                                        0 or omitted    US (NASD) 30/360
  *                                        1                Actual/actual
  *                                        2                Actual/360
  *                                        3                Actual/365
  *                                        4                European 30/360
  * @return    float
  */
 public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0)
 {
     $cost = Functions::flattenSingleValue($cost);
     $purchased = Functions::flattenSingleValue($purchased);
     $firstPeriod = Functions::flattenSingleValue($firstPeriod);
     $salvage = Functions::flattenSingleValue($salvage);
     $period = Functions::flattenSingleValue($period);
     $rate = Functions::flattenSingleValue($rate);
     $basis = is_null($basis) ? 0 : (int) Functions::flattenSingleValue($basis);
     $fOneRate = $cost * $rate;
     $fCostDelta = $cost - $salvage;
     //    Note, quirky variation for leap years on the YEARFRAC for this function
     $purchasedYear = DateTime::YEAR($purchased);
     $yearFrac = DateTime::YEARFRAC($purchased, $firstPeriod, $basis);
     if ($basis == 1 && $yearFrac < 1 && DateTime::isLeapYear($purchasedYear)) {
         $yearFrac *= 365 / 366;
     }
     $f0Rate = $yearFrac * $rate * $cost;
     $nNumOfFullPeriods = intval(($cost - $salvage - $f0Rate) / $fOneRate);
     if ($period == 0) {
         return $f0Rate;
     } elseif ($period <= $nNumOfFullPeriods) {
         return $fOneRate;
     } elseif ($period == $nNumOfFullPeriods + 1) {
         return $fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate;
     } else {
         return 0.0;
     }
 }
開發者ID:kameshwariv,項目名稱:testexample,代碼行數:55,代碼來源:Financial.php


注:本文中的DateTime::isLeapYear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。