diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 52dd290c..f53987f2 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -758,7 +758,7 @@ class Calculation ], 'DATE' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [DateTimeExcel\Datefunc::class, 'evaluate'], + 'functionCall' => [DateTimeExcel\Datefunc::class, 'fromYMD'], 'argumentCount' => '3', ], 'DATEDIF' => [ @@ -768,7 +768,7 @@ class Calculation ], 'DATEVALUE' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [DateTimeExcel\DateValue::class, 'evaluate'], + 'functionCall' => [DateTimeExcel\DateValue::class, 'fromString'], 'argumentCount' => '1', ], 'DAVERAGE' => [ @@ -2424,12 +2424,12 @@ class Calculation ], 'TIME' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [DateTimeExcel\Time::class, 'evaluate'], + 'functionCall' => [DateTimeExcel\Time::class, 'fromHMS'], 'argumentCount' => '3', ], 'TIMEVALUE' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, - 'functionCall' => [DateTimeExcel\TimeValue::class, 'evaluate'], + 'functionCall' => [DateTimeExcel\TimeValue::class, 'fromString'], 'argumentCount' => '1', ], 'TINV' => [ diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index a81190d4..dc2ec985 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -115,7 +115,7 @@ class DateTime * * @Deprecated 1.18.0 * - * @See DateTimeExcel\Datefunc::evaluate() + * @See DateTimeExcel\Datefunc::fromYMD() * Use the evaluate method in the DateTimeExcel\Datefunc class instead * * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. @@ -158,7 +158,7 @@ class DateTime */ public static function DATE($year = 0, $month = 1, $day = 1) { - return DateTimeExcel\Datefunc::evaluate($year, $month, $day); + return DateTimeExcel\Datefunc::fromYMD($year, $month, $day); } /** @@ -174,7 +174,7 @@ class DateTime * * @Deprecated 1.18.0 * - * @See DateTimeExcel\Time::evaluate() + * @See DateTimeExcel\Time::fromHMS() * Use the evaluate method in the DateTimeExcel\Time class instead * * @param int $hour A number from 0 (zero) to 32767 representing the hour. @@ -194,7 +194,7 @@ class DateTime */ public static function TIME($hour = 0, $minute = 0, $second = 0) { - return DateTimeExcel\Time::evaluate($hour, $minute, $second); + return DateTimeExcel\Time::fromHMS($hour, $minute, $second); } /** @@ -212,8 +212,8 @@ class DateTime * * @Deprecated 1.18.0 * - * @See DateTimeExcel\DateValue::evaluate() - * Use the evaluate method in the DateTimeExcel\DateValue class instead + * @See DateTimeExcel\DateValue::fromString() + * Use the fromString method in the DateTimeExcel\DateValue class instead * * @param string $dateValue Text that represents a date in a Microsoft Excel date format. * For example, "1/30/2008" or "30-Jan-2008" are text strings within @@ -229,7 +229,7 @@ class DateTime */ public static function DATEVALUE($dateValue) { - return DateTimeExcel\DateValue::evaluate($dateValue); + return DateTimeExcel\DateValue::fromString($dateValue); } /** @@ -247,8 +247,8 @@ class DateTime * * @Deprecated 1.18.0 * - * @See DateTimeExcel\TimeValue::evaluate() - * Use the evaluate method in the DateTimeExcel\TimeValue class instead + * @See DateTimeExcel\TimeValue::fromString() + * Use the fromString method in the DateTimeExcel\TimeValue class instead * * @param string $timeValue A text string that represents a time in any one of the Microsoft * Excel time formats; for example, "6:45 PM" and "18:45" text strings @@ -260,7 +260,7 @@ class DateTime */ public static function TIMEVALUE($timeValue) { - return DateTimeExcel\TimeValue::evaluate($timeValue); + return DateTimeExcel\TimeValue::fromString($timeValue); } /** diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php index ee872f31..4c754456 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php @@ -33,7 +33,7 @@ class DateValue * @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) + public static function fromString($dateValue) { $dti = new DateTimeImmutable(); $baseYear = Date::getExcelCalendar(); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Datefunc.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Datefunc.php index e8aa02cb..3a0aaeaa 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Datefunc.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Datefunc.php @@ -58,7 +58,7 @@ class Datefunc * @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($year, $month, $day) + public static function fromYMD($year, $month, $day) { $baseYear = Date::getExcelCalendar(); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 00f12ddc..2d1b6af1 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -43,7 +43,7 @@ class Helpers if (!is_numeric($dateValue)) { $saveReturnDateType = Functions::getReturnDateType(); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); - $dateValue = DateValue::evaluate($dateValue); + $dateValue = DateValue::fromString($dateValue); Functions::setReturnDateType($saveReturnDateType); if (!is_numeric($dateValue)) { throw new Exception(Functions::VALUE()); @@ -67,7 +67,7 @@ class Helpers { $saveReturnDateType = Functions::getReturnDateType(); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); - $timeValue = TimeValue::evaluate($timeValue); + $timeValue = TimeValue::fromString($timeValue); Functions::setReturnDateType($saveReturnDateType); return $timeValue; diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php index 7f29ba2c..c72bcf60 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php @@ -35,7 +35,7 @@ class Time * @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($hour, $minute, $second) + public static function fromHMS($hour, $minute, $second) { try { $hour = self::toIntWithNullBool($hour); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index 46fa4136..67600761 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -29,7 +29,7 @@ class TimeValue * @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($timeValue) + public static function fromString($timeValue) { $timeValue = trim(Functions::flattenSingleValue($timeValue), '"'); $timeValue = str_replace(['/', '.'], '-', $timeValue); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 3b7f0486..b360a0f6 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -98,7 +98,7 @@ class Format $format = Functions::flattenSingleValue($format); if ((is_string($value)) && (!is_numeric($value)) && Date::isDateTimeFormatCode($format)) { - $value = DateTimeExcel\DateValue::evaluate($value); + $value = DateTimeExcel\DateValue::fromString($value); } return (string) NumberFormat::toFormattedString($value, $format); @@ -129,14 +129,14 @@ class Format Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); if (strpos($value, ':') !== false) { - $timeValue = DateTimeExcel\TimeValue::evaluate($value); + $timeValue = DateTimeExcel\TimeValue::fromString($value); if ($timeValue !== Functions::VALUE()) { Functions::setReturnDateType($dateSetting); return $timeValue; } } - $dateValue = DateTimeExcel\DateValue::evaluate($value); + $dateValue = DateTimeExcel\DateValue::fromString($value); if ($dateValue !== Functions::VALUE()) { Functions::setReturnDateType($dateSetting); diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index a56ca3df..3b4c635d 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -437,14 +437,14 @@ class Date return false; } - $dateValueNew = DateTimeExcel\DateValue::evaluate($dateValue); + $dateValueNew = DateTimeExcel\DateValue::fromString($dateValue); if ($dateValueNew === Functions::VALUE()) { return false; } if (strpos($dateValue, ':') !== false) { - $timeValue = DateTimeExcel\TimeValue::evaluate($dateValue); + $timeValue = DateTimeExcel\TimeValue::fromString($dateValue); if ($timeValue === Functions::VALUE()) { return false; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index 28988ded..01e8d4a0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -29,7 +29,7 @@ class DateTest extends AllSetupTeardown { self::setUnixReturn(); - $result = Datefunc::evaluate(2012, 1, 31); // 32-bit safe + $result = Datefunc::fromYMD(2012, 1, 31); // 32-bit safe self::assertEquals(1327968000, $result); } @@ -37,7 +37,7 @@ class DateTest extends AllSetupTeardown { self::setObjectReturn(); - $result = Datefunc::evaluate(2012, 1, 31); + $result = Datefunc::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::evaluate(1918, 11, 11); + $result = Datefunc::fromYMD(1918, 11, 11); self::assertEquals($result, 5428); - $result = Datefunc::evaluate(1901, 1, 31); + $result = Datefunc::fromYMD(1901, 1, 31); self::assertEquals($result, '#NUM!'); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 13e56671..cf37162a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -26,7 +26,7 @@ class DateValueTest extends AllSetupTeardown if (is_string($expectedResult)) { $replYMD = str_replace('Y', date('Y'), $expectedResult); if ($replYMD !== $expectedResult) { - $expectedResult = DateValue::evaluate($replYMD); + $expectedResult = DateValue::fromString($replYMD); } } $this->sheet->getCell("A$row")->setValue("=DATEVALUE($dateValue)"); @@ -46,7 +46,7 @@ class DateValueTest extends AllSetupTeardown { self::setUnixReturn(); - $result = DateValue::evaluate('2012-1-31'); + $result = DateValue::fromString('2012-1-31'); self::assertEquals(1327968000, $result); self::assertEqualsWithDelta(1327968000, $result, 1E-8); } @@ -55,7 +55,7 @@ class DateValueTest extends AllSetupTeardown { self::setObjectReturn(); - $result = DateValue::evaluate('2012-1-31'); + $result = DateValue::fromString('2012-1-31'); // Must return an object... self::assertIsObject($result); // ... of the correct type @@ -67,9 +67,9 @@ class DateValueTest extends AllSetupTeardown public function testDATEVALUEwith1904Calendar(): void { self::setMac1904(); - self::assertEquals(5428, DateValue::evaluate('1918-11-11')); - self::assertEquals(0, DateValue::evaluate('1904-01-01')); - self::assertEquals('#VALUE!', DateValue::evaluate('1903-12-31')); - self::assertEquals('#VALUE!', DateValue::evaluate('1900-02-29')); + self::assertEquals(5428, DateValue::fromString('1918-11-11')); + self::assertEquals(0, DateValue::fromString('1904-01-01')); + self::assertEquals('#VALUE!', DateValue::fromString('1903-12-31')); + self::assertEquals('#VALUE!', DateValue::fromString('1900-02-29')); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 053385e7..ae83f05a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -31,7 +31,7 @@ class TimeTest extends AllSetupTeardown { self::setUnixReturn(); - $result = Time::evaluate(7, 30, 20); + $result = Time::fromHMS(7, 30, 20); self::assertEqualsWithDelta(27020, $result, 1E-8); } @@ -39,7 +39,7 @@ class TimeTest extends AllSetupTeardown { self::setObjectReturn(); - $result = Time::evaluate(7, 30, 20); + $result = Time::fromHMS(7, 30, 20); // Must return an object... self::assertIsObject($result); // ... of the correct type @@ -51,13 +51,13 @@ class TimeTest extends AllSetupTeardown public function testTIME1904(): void { self::setMac1904(); - $result = Time::evaluate(0, 0, 0); + $result = Time::fromHMS(0, 0, 0); self::assertEquals(0, $result); } public function testTIME1900(): void { - $result = Time::evaluate(0, 0, 0); + $result = Time::fromHMS(0, 0, 0); self::assertEquals(0, $result); } } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index 1eea77cb..23eb4f17 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -31,7 +31,7 @@ class TimeValueTest extends AllSetupTeardown { self::setUnixReturn(); - $result = TimeValue::evaluate('7:30:20'); + $result = TimeValue::fromString('7:30:20'); self::assertEquals(23420, $result); self::assertEqualsWithDelta(23420, $result, 1E-8); } @@ -40,7 +40,7 @@ class TimeValueTest extends AllSetupTeardown { self::setObjectReturn(); - $result = TimeValue::evaluate('7:30:20'); + $result = TimeValue::fromString('7:30:20'); // Must return an object... self::assertIsObject($result); // ... of the correct type