Renaming the last of the DateTime implementation methods
This commit is contained in:
parent
f7a07747fd
commit
765d4586ae
|
|
@ -758,12 +758,12 @@ class Calculation
|
|||
],
|
||||
'DATE' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\Datefunc::class, 'fromYMD'],
|
||||
'functionCall' => [DateTimeExcel\Date::class, 'fromYMD'],
|
||||
'argumentCount' => '3',
|
||||
],
|
||||
'DATEDIF' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\DateDif::class, 'interval'],
|
||||
'functionCall' => [DateTimeExcel\Difference::class, 'interval'],
|
||||
'argumentCount' => '2,3',
|
||||
],
|
||||
'DATEVALUE' => [
|
||||
|
|
@ -1764,7 +1764,7 @@ class Calculation
|
|||
],
|
||||
'NETWORKDAYS' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\NetworkDays::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\NetworkDays::class, 'count'],
|
||||
'argumentCount' => '2-3',
|
||||
],
|
||||
'NETWORKDAYS.INTL' => [
|
||||
|
|
@ -2594,7 +2594,7 @@ class Calculation
|
|||
],
|
||||
'WORKDAY' => [
|
||||
'category' => Category::CATEGORY_DATE_AND_TIME,
|
||||
'functionCall' => [DateTimeExcel\WorkDay::class, 'evaluate'],
|
||||
'functionCall' => [DateTimeExcel\WorkDay::class, 'date'],
|
||||
'argumentCount' => '2-3',
|
||||
],
|
||||
'WORKDAY.INTL' => [
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\Datefunc::fromYMD()
|
||||
* Use the fromYMD method in the DateTimeExcel\Datefunc class instead
|
||||
* @See DateTimeExcel\Date::fromYMD()
|
||||
* Use the fromYMD method in the DateTimeExcel\Date 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,
|
||||
|
|
@ -158,7 +158,7 @@ class DateTime
|
|||
*/
|
||||
public static function DATE($year = 0, $month = 1, $day = 1)
|
||||
{
|
||||
return DateTimeExcel\Datefunc::fromYMD($year, $month, $day);
|
||||
return DateTimeExcel\Date::fromYMD($year, $month, $day);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,8 +271,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\DateDif::interval()
|
||||
* Use the interval method in the DateTimeExcel\DateDif class instead
|
||||
* @See DateTimeExcel\Difference::interval()
|
||||
* Use the interval method in the DateTimeExcel\Difference 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::interval($startDate, $endDate, $unit);
|
||||
return DateTimeExcel\Difference::interval($startDate, $endDate, $unit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -400,8 +400,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\NetworkDays::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\NetworkDays class instead
|
||||
* @See DateTimeExcel\NetworkDays::count()
|
||||
* Use the count method in the DateTimeExcel\NetworkDays class instead
|
||||
*
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
|
@ -413,7 +413,7 @@ class DateTime
|
|||
*/
|
||||
public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs)
|
||||
{
|
||||
return DateTimeExcel\NetworkDays::evaluate($startDate, $endDate, ...$dateArgs);
|
||||
return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -429,8 +429,8 @@ class DateTime
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See DateTimeExcel\WorkDay::evaluate()
|
||||
* Use the evaluate method in the DateTimeExcel\WorkDay class instead
|
||||
* @See DateTimeExcel\WorkDay::date()
|
||||
* Use the date method in the DateTimeExcel\WorkDay class instead
|
||||
*
|
||||
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer),
|
||||
* PHP DateTime object, or a standard date string
|
||||
|
|
@ -444,7 +444,7 @@ class DateTime
|
|||
*/
|
||||
public static function WORKDAY($startDate, $endDays, ...$dateArgs)
|
||||
{
|
||||
return DateTimeExcel\WorkDay::evaluate($startDate, $endDays, ...$dateArgs);
|
||||
return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
|
|||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
|
||||
class Datefunc
|
||||
class Date
|
||||
{
|
||||
/**
|
||||
* DATE.
|
||||
|
|
@ -60,7 +60,7 @@ class Datefunc
|
|||
*/
|
||||
public static function fromYMD($year, $month, $day)
|
||||
{
|
||||
$baseYear = Date::getExcelCalendar();
|
||||
$baseYear = SharedDateHelper::getExcelCalendar();
|
||||
|
||||
try {
|
||||
$year = self::getYear($year, $baseYear);
|
||||
|
|
@ -72,7 +72,7 @@ class Datefunc
|
|||
}
|
||||
|
||||
// Execute function
|
||||
$excelDateValue = Date::formattedPHPToExcel($year, $month, $day);
|
||||
$excelDateValue = SharedDateHelper::formattedPHPToExcel($year, $month, $day);
|
||||
|
||||
return Helpers::returnIn3FormatsFloat($excelDateValue);
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ class Datefunc
|
|||
$month = Functions::flattenSingleValue($month);
|
||||
|
||||
if (($month !== null) && (!is_numeric($month))) {
|
||||
$month = Date::monthStringToNumber($month);
|
||||
$month = SharedDateHelper::monthStringToNumber($month);
|
||||
}
|
||||
|
||||
$month = ($month !== null) ? StringHelper::testStringAsNumeric((string) $month) : 0;
|
||||
|
|
@ -136,7 +136,7 @@ class Datefunc
|
|||
$day = Functions::flattenSingleValue($day);
|
||||
|
||||
if (($day !== null) && (!is_numeric($day))) {
|
||||
$day = Date::dayStringToNumber($day);
|
||||
$day = SharedDateHelper::dayStringToNumber($day);
|
||||
}
|
||||
|
||||
$day = ($day !== null) ? StringHelper::testStringAsNumeric((string) $day) : 0;
|
||||
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
|
||||
class DateDif
|
||||
class Difference
|
||||
{
|
||||
/**
|
||||
* DATEDIF.
|
||||
|
|
@ -27,7 +27,7 @@ class NetworkDays
|
|||
*
|
||||
* @return int|string Interval between the dates
|
||||
*/
|
||||
public static function evaluate($startDate, $endDate, ...$dateArgs)
|
||||
public static function count($startDate, $endDate, ...$dateArgs)
|
||||
{
|
||||
try {
|
||||
// Retrieve the mandatory start and end date that are referenced in the function definition
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class WorkDay
|
|||
* @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($startDate, $endDays, ...$dateArgs)
|
||||
public static function date($startDate, $endDays, ...$dateArgs)
|
||||
{
|
||||
// Retrieve the mandatory start date and days that are referenced in the function definition
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ class YearFrac
|
|||
case 1:
|
||||
return self::method1($startDate, $endDate);
|
||||
case 2:
|
||||
return DateDif::interval($startDate, $endDate) / 360;
|
||||
return Difference::interval($startDate, $endDate) / 360;
|
||||
case 3:
|
||||
return DateDif::interval($startDate, $endDate) / 365;
|
||||
return Difference::interval($startDate, $endDate) / 365;
|
||||
case 4:
|
||||
return Days360::between($startDate, $endDate, true) / 360;
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ class YearFrac
|
|||
|
||||
private static function method1(float $startDate, float $endDate): float
|
||||
{
|
||||
$days = DateDif::interval($startDate, $endDate);
|
||||
$days = Difference::interval($startDate, $endDate);
|
||||
$startYear = (int) DateParts::year($startDate);
|
||||
$endYear = (int) DateParts::year($endDate);
|
||||
$years = $endYear - $startYear + 1;
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ class NonPeriodic
|
|||
return $e->getMessage();
|
||||
}
|
||||
if ($date0 > $datei) {
|
||||
$dif = $ordered ? Functions::NAN() : -((int) DateTimeExcel\DateDif::interval($datei, $date0, 'd'));
|
||||
$dif = $ordered ? Functions::NAN() : -((int) DateTimeExcel\Difference::interval($datei, $date0, 'd'));
|
||||
} else {
|
||||
$dif = DateTimeExcel\DateDif::interval($date0, $datei, 'd');
|
||||
$dif = DateTimeExcel\Difference::interval($date0, $datei, 'd');
|
||||
}
|
||||
if (!is_numeric($dif)) {
|
||||
return $dif;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Datefunc;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Date;
|
||||
|
||||
class DateTest extends AllSetupTeardown
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class DateTest extends AllSetupTeardown
|
|||
{
|
||||
self::setUnixReturn();
|
||||
|
||||
$result = Datefunc::fromYMD(2012, 1, 31); // 32-bit safe
|
||||
$result = Date::fromYMD(2012, 1, 31); // 32-bit safe
|
||||
self::assertEquals(1327968000, $result);
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ class DateTest extends AllSetupTeardown
|
|||
{
|
||||
self::setObjectReturn();
|
||||
|
||||
$result = Datefunc::fromYMD(2012, 1, 31);
|
||||
$result = Date::fromYMD(2012, 1, 31);
|
||||
// Must return an object...
|
||||
self::assertIsObject($result);
|
||||
// ... of the correct type
|
||||
|
|
@ -50,10 +50,10 @@ class DateTest extends AllSetupTeardown
|
|||
{
|
||||
self::setMac1904();
|
||||
|
||||
$result = Datefunc::fromYMD(1918, 11, 11);
|
||||
$result = Date::fromYMD(1918, 11, 11);
|
||||
self::assertEquals($result, 5428);
|
||||
|
||||
$result = Datefunc::fromYMD(1901, 1, 31);
|
||||
$result = Date::fromYMD(1901, 1, 31);
|
||||
self::assertEquals($result, '#NUM!');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue