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


PHP PHPExcel_Calculation_DateTime::_isLeapYear方法代码示例

本文整理汇总了PHP中PHPExcel_Calculation_DateTime::_isLeapYear方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_DateTime::_isLeapYear方法的具体用法?PHP PHPExcel_Calculation_DateTime::_isLeapYear怎么用?PHP PHPExcel_Calculation_DateTime::_isLeapYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Calculation_DateTime的用法示例。


在下文中一共展示了PHPExcel_Calculation_DateTime::_isLeapYear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
     $purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
     $firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod);
     $salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
     $period = PHPExcel_Calculation_Functions::flattenSingleValue($period);
     $rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
     $basis = is_null($basis) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
     $fOneRate = $cost * $rate;
     $fCostDelta = $cost - $salvage;
     //	Note, quirky variation for leap years on the YEARFRAC for this function
     $purchasedYear = PHPExcel_Calculation_DateTime::YEAR($purchased);
     $yearFrac = PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis);
     if ($basis == 1 && $yearFrac < 1 && PHPExcel_Calculation_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:arjunkumar786,项目名称:faces,代码行数:55,代码来源:Financial.php

示例2: _daysPerYear

 /**
  * _daysPerYear
  *
  * Returns the number of days in a specified year, as defined by the "basis" value
  *
  * @param    integer $year            The year against which we're testing
  * @param   integer  $basis           The type of day count:
  *                                    0 or omitted US (NASD)    360
  *                                    1                        Actual (365 or 366 in a leap year)
  *                                    2                        360
  *                                    3                        365
  *                                    4                        European 360
  *
  * @return    integer
  */
 private static function _daysPerYear($year, $basis = 0)
 {
     switch ($basis) {
         case 0:
         case 2:
         case 4:
             $daysPerYear = 360;
             break;
         case 3:
             $daysPerYear = 365;
             break;
         case 1:
             $daysPerYear = PHPExcel_Calculation_DateTime::_isLeapYear($year) ? 366 : 365;
             break;
         default:
             return PHPExcel_Calculation_Functions::NaN();
     }
     return $daysPerYear;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:34,代码来源:Financial.php


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