More method renaming
This commit is contained in:
parent
aa3269a863
commit
f7a07747fd
|
|
@ -763,7 +763,7 @@ class Calculation
|
|||
],
|
||||
'DATEDIF' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\DateDif::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\DateDif::class, 'interval'],
|
||||
'argumentCount' => '2,3',
|
||||
],
|
||||
'DATEVALUE' => [
|
||||
|
|
@ -783,12 +783,12 @@ class Calculation
|
|||
],
|
||||
'DAYS' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\Days::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\Days::class, 'between'],
|
||||
'argumentCount' => '2',
|
||||
],
|
||||
'DAYS360' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\Days360::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\Days360::class, 'between'],
|
||||
'argumentCount' => '2,3',
|
||||
],
|
||||
'DB' => [
|
||||
|
|
@ -923,7 +923,7 @@ class Calculation
|
|||
],
|
||||
'EDATE' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\EDate::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\Month::class, 'adjust'],
|
||||
'argumentCount' => '2',
|
||||
],
|
||||
'EFFECT' => [
|
||||
|
|
@ -938,7 +938,7 @@ class Calculation
|
|||
],
|
||||
'EOMONTH' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\EoMonth::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\Month::class, 'lastDay'],
|
||||
'argumentCount' => '2',
|
||||
],
|
||||
'ERF' => [
|
||||
|
|
@ -2634,7 +2634,7 @@ class Calculation
|
|||
],
|
||||
'YEARFRAC' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\YearFrac::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\YearFrac::class, 'fraction'],
|
||||
'argumentCount' => '2,3',
|
||||
],
|
||||
'YIELD' => [
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class DateTime
|
|||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Datefunc::fromYMD()
|
||||
* Use the evaluate method in the DateTimeExcel\Datefunc class instead
|
||||
* Use the fromYMD method in the DateTimeExcel\Datefunc class instead
|
||||
*
|
||||
* PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function.
|
||||
* A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted,
|
||||
|
|
@ -175,7 +175,7 @@ class DateTime
|
|||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Time::fromHMS()
|
||||
* Use the evaluate method in the DateTimeExcel\Time class instead
|
||||
* Use the fromHMS method in the DateTimeExcel\Time class instead
|
||||
*
|
||||
* @param int $hour A number from 0 (zero) to 32767 representing the hour.
|
||||
* Any value greater than 23 will be divided by 24 and the remainder
|
||||
|
|
@ -271,8 +271,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\DateDif::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\DateDif class instead
|
||||
* @See DateTimeExcel\DateDif::interval()
|
||||
* Use the interval method in the DateTimeExcel\DateDif class instead
|
||||
*
|
||||
* @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object
|
||||
* or a standard date string
|
||||
|
|
@ -284,7 +284,7 @@ class DateTime
|
|||
*/
|
||||
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
|
||||
{
|
||||
return DateTimeExcel\DateDif::evaluate($startDate, $endDate, $unit);
|
||||
return DateTimeExcel\DateDif::interval($startDate, $endDate, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,8 +297,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Days::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\Days class instead
|
||||
* @See DateTimeExcel\Days::between()
|
||||
* Use the between method in the DateTimeExcel\Days class instead
|
||||
*
|
||||
* @param DateTimeInterface|float|int|string $endDate Excel date serial value (float),
|
||||
* PHP date timestamp (integer), PHP DateTime object, or a standard date string
|
||||
|
|
@ -309,7 +309,7 @@ class DateTime
|
|||
*/
|
||||
public static function DAYS($endDate = 0, $startDate = 0)
|
||||
{
|
||||
return DateTimeExcel\Days::evaluate($endDate, $startDate);
|
||||
return DateTimeExcel\Days::between($endDate, $startDate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -324,8 +324,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Days360::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\Days360 class instead
|
||||
* @See DateTimeExcel\Days360::between()
|
||||
* Use the between method in the DateTimeExcel\Days360 class instead
|
||||
*
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
|
@ -347,7 +347,7 @@ class DateTime
|
|||
*/
|
||||
public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
|
||||
{
|
||||
return DateTimeExcel\Days360::evaluate($startDate, $endDate, $method);
|
||||
return DateTimeExcel\Days360::between($startDate, $endDate, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -363,8 +363,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\YearFrac::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\YearFrac class instead
|
||||
* @See DateTimeExcel\YearFrac::fraction()
|
||||
* Use the fraction method in the DateTimeExcel\YearFrac class instead
|
||||
*
|
||||
* See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html
|
||||
* for description of algorithm used in Excel
|
||||
|
|
@ -384,7 +384,7 @@ class DateTime
|
|||
*/
|
||||
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
|
||||
{
|
||||
return DateTimeExcel\YearFrac::evaluate($startDate, $endDate, $method);
|
||||
return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -867,8 +867,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Edate::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\Edate class instead
|
||||
* @See DateTimeExcel\Month::adjust()
|
||||
* Use the adjust method in the DateTimeExcel\Edate class instead
|
||||
*
|
||||
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
|
@ -881,7 +881,7 @@ class DateTime
|
|||
*/
|
||||
public static function EDATE($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
return DateTimeExcel\EDate::evaluate($dateValue, $adjustmentMonths);
|
||||
return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -896,8 +896,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\EoMonth::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\EoMonth class instead
|
||||
* @See DateTimeExcel\Month::lastDay()
|
||||
* Use the lastDay method in the DateTimeExcel\EoMonth class instead
|
||||
*
|
||||
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
|
@ -910,6 +910,6 @@ class DateTime
|
|||
*/
|
||||
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
return DateTimeExcel\EoMonth::evaluate($dateValue, $adjustmentMonths);
|
||||
return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class DateDif
|
|||
*
|
||||
* @return int|string Interval between the dates
|
||||
*/
|
||||
public static function evaluate($startDate, $endDate, $unit = 'D')
|
||||
public static function interval($startDate, $endDate, $unit = 'D')
|
||||
{
|
||||
try {
|
||||
$startDate = Helpers::getDateValue($startDate);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Days
|
|||
*
|
||||
* @return int|string Number of days between start date and end date or an error
|
||||
*/
|
||||
public static function evaluate($endDate, $startDate)
|
||||
public static function between($endDate, $startDate)
|
||||
{
|
||||
try {
|
||||
$startDate = Helpers::getDateValue($startDate);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Days360
|
|||
*
|
||||
* @return int|string Number of days between start date and end date
|
||||
*/
|
||||
public static function evaluate($startDate = 0, $endDate = 0, $method = false)
|
||||
public static function between($startDate = 0, $endDate = 0, $method = false)
|
||||
{
|
||||
try {
|
||||
$startDate = Helpers::getDateValue($startDate);
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
class EDate
|
||||
{
|
||||
/**
|
||||
* EDATE.
|
||||
*
|
||||
* Returns the serial number that represents the date that is the indicated number of months
|
||||
* before or after a specified date (the start_date).
|
||||
* Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
|
||||
* as the date of issue.
|
||||
*
|
||||
* Excel Function:
|
||||
* EDATE(dateValue,adjustmentMonths)
|
||||
*
|
||||
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param int $adjustmentMonths The number of months before or after start_date.
|
||||
* A positive value for months yields a future date;
|
||||
* a negative value yields a past date.
|
||||
*
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function evaluate($dateValue, $adjustmentMonths)
|
||||
{
|
||||
try {
|
||||
$dateValue = Helpers::getDateValue($dateValue, false);
|
||||
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
// Execute function
|
||||
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||
|
||||
return Helpers::returnIn3FormatsObject($PHPDateObject);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,44 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
|
|||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
class EoMonth
|
||||
class Month
|
||||
{
|
||||
/**
|
||||
* EDATE.
|
||||
*
|
||||
* Returns the serial number that represents the date that is the indicated number of months
|
||||
* before or after a specified date (the start_date).
|
||||
* Use EDATE to calculate maturity dates or due dates that fall on the same day of the month
|
||||
* as the date of issue.
|
||||
*
|
||||
* Excel Function:
|
||||
* EDATE(dateValue,adjustmentMonths)
|
||||
*
|
||||
* @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @param int $adjustmentMonths The number of months before or after start_date.
|
||||
* A positive value for months yields a future date;
|
||||
* a negative value yields a past date.
|
||||
*
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function adjust($dateValue, $adjustmentMonths)
|
||||
{
|
||||
try {
|
||||
$dateValue = Helpers::getDateValue($dateValue, false);
|
||||
$adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
// Execute function
|
||||
$PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||
|
||||
return Helpers::returnIn3FormatsObject($PHPDateObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* EOMONTH.
|
||||
*
|
||||
|
|
@ -26,7 +62,7 @@ class EoMonth
|
|||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function evaluate($dateValue, $adjustmentMonths)
|
||||
public static function lastDay($dateValue, $adjustmentMonths)
|
||||
{
|
||||
try {
|
||||
$dateValue = Helpers::getDateValue($dateValue, false);
|
||||
|
|
@ -34,7 +34,7 @@ class YearFrac
|
|||
*
|
||||
* @return float|string fraction of the year, or a string containing an error
|
||||
*/
|
||||
public static function evaluate($startDate, $endDate, $method = 0)
|
||||
public static function fraction($startDate, $endDate, $method = 0)
|
||||
{
|
||||
try {
|
||||
$method = (int) Helpers::validateNumericNull($method);
|
||||
|
|
@ -50,15 +50,15 @@ class YearFrac
|
|||
|
||||
switch ($method) {
|
||||
case 0:
|
||||
return Days360::evaluate($startDate, $endDate) / 360;
|
||||
return Days360::between($startDate, $endDate) / 360;
|
||||
case 1:
|
||||
return self::method1($startDate, $endDate);
|
||||
case 2:
|
||||
return DateDif::evaluate($startDate, $endDate) / 360;
|
||||
return DateDif::interval($startDate, $endDate) / 360;
|
||||
case 3:
|
||||
return DateDif::evaluate($startDate, $endDate) / 365;
|
||||
return DateDif::interval($startDate, $endDate) / 365;
|
||||
case 4:
|
||||
return Days360::evaluate($startDate, $endDate, true) / 360;
|
||||
return Days360::between($startDate, $endDate, true) / 360;
|
||||
}
|
||||
|
||||
return Functions::NAN();
|
||||
|
|
@ -87,7 +87,7 @@ class YearFrac
|
|||
|
||||
private static function method1(float $startDate, float $endDate): float
|
||||
{
|
||||
$days = DateDif::evaluate($startDate, $endDate);
|
||||
$days = DateDif::interval($startDate, $endDate);
|
||||
$startYear = (int) DateParts::year($startDate);
|
||||
$endYear = (int) DateParts::year($endDate);
|
||||
$years = $endYear - $startYear + 1;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class Amortization
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$yearFrac = DateTimeExcel\YearFrac::evaluate($purchased, $firstPeriod, $basis);
|
||||
$yearFrac = DateTimeExcel\YearFrac::fraction($purchased, $firstPeriod, $basis);
|
||||
if (is_string($yearFrac)) {
|
||||
return $yearFrac;
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ class Amortization
|
|||
$fCostDelta = $cost - $salvage;
|
||||
// Note, quirky variation for leap years on the YEARFRAC for this function
|
||||
$purchasedYear = DateTimeExcel\DateParts::year($purchased);
|
||||
$yearFrac = DateTimeExcel\YearFrac::evaluate($purchased, $firstPeriod, $basis);
|
||||
$yearFrac = DateTimeExcel\YearFrac::fraction($purchased, $firstPeriod, $basis);
|
||||
if (is_string($yearFrac)) {
|
||||
return $yearFrac;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ class NonPeriodic
|
|||
return $e->getMessage();
|
||||
}
|
||||
if ($date0 > $datei) {
|
||||
$dif = $ordered ? Functions::NAN() : -((int) DateTimeExcel\DateDif::evaluate($datei, $date0, 'd'));
|
||||
$dif = $ordered ? Functions::NAN() : -((int) DateTimeExcel\DateDif::interval($datei, $date0, 'd'));
|
||||
} else {
|
||||
$dif = DateTimeExcel\DateDif::evaluate($date0, $datei, 'd');
|
||||
$dif = DateTimeExcel\DateDif::interval($date0, $datei, 'd');
|
||||
}
|
||||
if (!is_numeric($dif)) {
|
||||
return $dif;
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ class Coupons
|
|||
$prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_PREVIOUS);
|
||||
|
||||
if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) {
|
||||
return abs((float) DateTimeExcel\Days::evaluate($prev, $settlement));
|
||||
return abs((float) DateTimeExcel\Days::between($prev, $settlement));
|
||||
}
|
||||
|
||||
return DateTimeExcel\YearFrac::evaluate($prev, $settlement, $basis) * $daysPerYear;
|
||||
return DateTimeExcel\YearFrac::fraction($prev, $settlement, $basis) * $daysPerYear;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -208,7 +208,7 @@ class Coupons
|
|||
}
|
||||
}
|
||||
|
||||
return DateTimeExcel\YearFrac::evaluate($settlement, $next, $basis) * $daysPerYear;
|
||||
return DateTimeExcel\YearFrac::fraction($settlement, $next, $basis) * $daysPerYear;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -316,7 +316,7 @@ class Coupons
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate(
|
||||
$yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction(
|
||||
$settlement,
|
||||
$maturity,
|
||||
FinancialConstants::BASIS_DAYS_PER_YEAR_NASD
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ class AccruedInterest
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenIssueAndSettlement = YearFrac::evaluate($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenFirstInterestAndSettlement = YearFrac::evaluate($firstInterest, $settlement, $basis);
|
||||
$daysBetweenFirstInterestAndSettlement = YearFrac::fraction($firstInterest, $settlement, $basis);
|
||||
if (!is_numeric($daysBetweenFirstInterestAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenFirstInterestAndSettlement;
|
||||
|
|
@ -140,7 +140,7 @@ class AccruedInterest
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenIssueAndSettlement = YearFrac::evaluate($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = YearFrac::fraction($issue, $settlement, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class Price
|
|||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -198,19 +198,19 @@ class Price
|
|||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::evaluate($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement *= $daysPerYear;
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::evaluate($issue, $maturity, $basis);
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndMaturity;
|
||||
}
|
||||
$daysBetweenIssueAndMaturity *= $daysPerYear;
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -272,7 +272,7 @@ class Price
|
|||
if ($investment <= 0) {
|
||||
return Functions::NAN();
|
||||
}
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class Rates
|
|||
return Functions::NAN();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -126,7 +126,7 @@ class Rates
|
|||
return Functions::NAN();
|
||||
}
|
||||
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Yields
|
|||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
@ -126,19 +126,19 @@ class Yields
|
|||
if (!is_numeric($daysPerYear)) {
|
||||
return $daysPerYear;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::evaluate($issue, $settlement, $basis);
|
||||
$daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::fraction($issue, $settlement, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndSettlement)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndSettlement;
|
||||
}
|
||||
$daysBetweenIssueAndSettlement *= $daysPerYear;
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::evaluate($issue, $maturity, $basis);
|
||||
$daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::fraction($issue, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenIssueAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenIssueAndMaturity;
|
||||
}
|
||||
$daysBetweenIssueAndMaturity *= $daysPerYear;
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::evaluate($settlement, $maturity, $basis);
|
||||
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
|
||||
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
|
||||
// return date error
|
||||
return $daysBetweenSettlementAndMaturity;
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ class DaysTest extends AllSetupTeardown
|
|||
{
|
||||
$obj1 = new DateTime('2000-3-31');
|
||||
$obj2 = new DateTimeImmutable('2000-2-29');
|
||||
self::assertSame(31, Days::evaluate($obj1, $obj2));
|
||||
self::assertSame(31, Days::between($obj1, $obj2));
|
||||
}
|
||||
|
||||
public function testNonDateObject(): void
|
||||
{
|
||||
$obj1 = new Exception();
|
||||
$obj2 = new DateTimeImmutable('2000-2-29');
|
||||
self::assertSame('#VALUE!', Days::evaluate($obj1, $obj2));
|
||||
self::assertSame('#VALUE!', Days::between($obj1, $obj2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\EDate;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Month;
|
||||
|
||||
class EDateTest extends AllSetupTeardown
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class EDateTest extends AllSetupTeardown
|
|||
{
|
||||
self::setUnixReturn();
|
||||
|
||||
$result = EDate::evaluate('2012-1-26', -1);
|
||||
$result = Month::adjust('2012-1-26', -1);
|
||||
self::assertEquals(1324857600, $result);
|
||||
self::assertEqualsWithDelta(1324857600, $result, 1E-8);
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ class EDateTest extends AllSetupTeardown
|
|||
{
|
||||
self::setObjectReturn();
|
||||
|
||||
$result = EDate::evaluate('2012-1-26', -1);
|
||||
$result = Month::adjust('2012-1-26', -1);
|
||||
// Must return an object...
|
||||
self::assertIsObject($result);
|
||||
// ... of the correct type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\EoMonth;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Month;
|
||||
|
||||
class EoMonthTest extends AllSetupTeardown
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class EoMonthTest extends AllSetupTeardown
|
|||
{
|
||||
self::setUnixReturn();
|
||||
|
||||
$result = EoMonth::evaluate('2012-1-26', -1);
|
||||
$result = Month::lastDay('2012-1-26', -1);
|
||||
self::assertEquals(1325289600, $result);
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ class EoMonthTest extends AllSetupTeardown
|
|||
{
|
||||
self::setObjectReturn();
|
||||
|
||||
$result = EoMonth::evaluate('2012-1-26', -1);
|
||||
$result = Month::lastDay('2012-1-26', -1);
|
||||
// Must return an object...
|
||||
self::assertIsObject($result);
|
||||
// ... of the correct type
|
||||
|
|
|
|||
Loading…
Reference in New Issue