本文整理汇总了PHP中PHPExcel_Calculation_DateTime::_getDateValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_DateTime::_getDateValue方法的具体用法?PHP PHPExcel_Calculation_DateTime::_getDateValue怎么用?PHP PHPExcel_Calculation_DateTime::_getDateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Calculation_DateTime
的用法示例。
在下文中一共展示了PHPExcel_Calculation_DateTime::_getDateValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TBILLYIELD
/**
* TBILLYIELD
*
* Returns the yield for a Treasury bill.
*
* @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
* @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int price The Treasury bill's price per $100 face value.
* @return float
*/
public static function TBILLYIELD($settlement, $maturity, $price)
{
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$price = PHPExcel_Calculation_Functions::flattenSingleValue($price);
// Validate
if (is_numeric($price)) {
if ($price <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
++$maturity;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360;
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
} else {
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity) - PHPExcel_Calculation_DateTime::_getDateValue($settlement);
}
if ($daysBetweenSettlementAndMaturity > 360) {
return PHPExcel_Calculation_Functions::NaN();
}
return (100 - $price) / $price * (360 / $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
}