Merge remote-tracking branch 'origin/master'

This commit is contained in:
MarkBaker 2019-07-21 22:02:18 +02:00
commit 20751dd1cd
53 changed files with 1064 additions and 920 deletions

View File

@ -16,7 +16,7 @@ class DateTime
*/ */
public static function isLeapYear($year) public static function isLeapYear($year)
{ {
return (($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0); return (($year % 4) === 0) && (($year % 100) !== 0) || (($year % 400) === 0);
} }
/** /**
@ -156,11 +156,11 @@ class DateTime
$retValue = (float) Date::PHPToExcel(time()); $retValue = (float) Date::PHPToExcel(time());
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
$retValue = (int) time(); $retValue = (int) time();
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
$retValue = new \DateTime(); $retValue = new \DateTime();
break; break;
@ -200,11 +200,11 @@ class DateTime
$retValue = (float) $excelDateTime; $retValue = (float) $excelDateTime;
break; break;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
$retValue = (int) Date::excelToTimestamp($excelDateTime); $retValue = (int) Date::excelToTimestamp($excelDateTime);
break; break;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
$retValue = Date::excelToDateTimeObject($excelDateTime); $retValue = Date::excelToDateTimeObject($excelDateTime);
break; break;
@ -325,9 +325,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp($excelDateValue); return (int) Date::excelToTimestamp($excelDateValue);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return Date::excelToDateTimeObject($excelDateValue); return Date::excelToDateTimeObject($excelDateValue);
} }
} }
@ -420,9 +420,9 @@ class DateTime
} }
return (float) Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); return (float) Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp(Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 return (int) Date::excelToTimestamp(Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
$dayAdjust = 0; $dayAdjust = 0;
if ($hour < 0) { if ($hour < 0) {
$dayAdjust = floor($hour / 24); $dayAdjust = floor($hour / 24);
@ -472,7 +472,6 @@ class DateTime
*/ */
public static function DATEVALUE($dateValue = 1) public static function DATEVALUE($dateValue = 1)
{ {
$dateValueOrig = $dateValue;
$dateValue = trim(Functions::flattenSingleValue($dateValue), '"'); $dateValue = trim(Functions::flattenSingleValue($dateValue), '"');
// Strip any ordinals because they're allowed in Excel (English only) // Strip any ordinals because they're allowed in Excel (English only)
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue); $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue);
@ -569,9 +568,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp($excelDateValue); return (int) Date::excelToTimestamp($excelDateValue);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00'); return new \DateTime($PHPDateArray['year'] . '-' . $PHPDateArray['month'] . '-' . $PHPDateArray['day'] . ' 00:00:00');
} }
} }
@ -631,9 +630,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $excelDateValue; return (float) $excelDateValue;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) $phpDateValue = Date::excelToTimestamp($excelDateValue + 25569) - 3600; return (int) $phpDateValue = Date::excelToTimestamp($excelDateValue + 25569) - 3600;
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']); return new \DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']);
} }
} }
@ -683,7 +682,6 @@ class DateTime
$endMonths = $PHPEndDateObject->format('n'); $endMonths = $PHPEndDateObject->format('n');
$endYears = $PHPEndDateObject->format('Y'); $endYears = $PHPEndDateObject->format('Y');
$retVal = Functions::NAN();
switch ($unit) { switch ($unit) {
case 'D': case 'D':
$retVal = (int) $difference; $retVal = (int) $difference;
@ -1154,9 +1152,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) $endDate; return (float) $endDate;
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp($endDate); return (int) Date::excelToTimestamp($endDate);
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return Date::excelToDateTimeObject($endDate); return Date::excelToDateTimeObject($endDate);
} }
} }
@ -1239,7 +1237,7 @@ class DateTime
// Execute function // Execute function
$PHPDateObject = Date::excelToDateTimeObject($dateValue); $PHPDateObject = Date::excelToDateTimeObject($dateValue);
$DoW = $PHPDateObject->format('w'); $DoW = (int) $PHPDateObject->format('w');
$firstDay = 1; $firstDay = 1;
switch ($style) { switch ($style) {
@ -1248,13 +1246,13 @@ class DateTime
break; break;
case 2: case 2:
if ($DoW == 0) { if ($DoW === 0) {
$DoW = 7; $DoW = 7;
} }
break; break;
case 3: case 3:
if ($DoW == 0) { if ($DoW === 0) {
$DoW = 7; $DoW = 7;
} }
$firstDay = 0; $firstDay = 0;
@ -1272,7 +1270,7 @@ class DateTime
} }
} }
return (int) $DoW; return $DoW;
} }
/** /**
@ -1591,9 +1589,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) Date::PHPToExcel($PHPDateObject); return (float) Date::PHPToExcel($PHPDateObject);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject)); return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject));
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return $PHPDateObject; return $PHPDateObject;
} }
} }
@ -1640,9 +1638,9 @@ class DateTime
switch (Functions::getReturnDateType()) { switch (Functions::getReturnDateType()) {
case Functions::RETURNDATE_EXCEL: case Functions::RETURNDATE_EXCEL:
return (float) Date::PHPToExcel($PHPDateObject); return (float) Date::PHPToExcel($PHPDateObject);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_UNIX_TIMESTAMP:
return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject)); return (int) Date::excelToTimestamp(Date::PHPToExcel($PHPDateObject));
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_DATETIME_OBJECT:
return $PHPDateObject; return $PHPDateObject;
} }
} }

View File

@ -17,8 +17,11 @@ class Functions
const COMPATIBILITY_EXCEL = 'Excel'; const COMPATIBILITY_EXCEL = 'Excel';
const COMPATIBILITY_GNUMERIC = 'Gnumeric'; const COMPATIBILITY_GNUMERIC = 'Gnumeric';
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'; const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
const RETURNDATE_PHP_NUMERIC = 'P'; const RETURNDATE_PHP_NUMERIC = 'P';
const RETURNDATE_UNIX_TIMESTAMP = 'P';
const RETURNDATE_PHP_OBJECT = 'O'; const RETURNDATE_PHP_OBJECT = 'O';
const RETURNDATE_PHP_DATETIME_OBJECT = 'O';
const RETURNDATE_EXCEL = 'E'; const RETURNDATE_EXCEL = 'E';
/** /**
@ -101,16 +104,16 @@ class Functions
* *
* @param string $returnDateType Return Date Format * @param string $returnDateType Return Date Format
* Permitted values are: * Permitted values are:
* Functions::RETURNDATE_PHP_NUMERIC 'P' * Functions::RETURNDATE_UNIX_TIMESTAMP 'P'
* Functions::RETURNDATE_PHP_OBJECT 'O' * Functions::RETURNDATE_PHP_DATETIME_OBJECT 'O'
* Functions::RETURNDATE_EXCEL 'E' * Functions::RETURNDATE_EXCEL 'E'
* *
* @return bool Success or failure * @return bool Success or failure
*/ */
public static function setReturnDateType($returnDateType) public static function setReturnDateType($returnDateType)
{ {
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) || if (($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) ||
($returnDateType == self::RETURNDATE_PHP_OBJECT) || ($returnDateType == self::RETURNDATE_PHP_DATETIME_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL) ($returnDateType == self::RETURNDATE_EXCEL)
) { ) {
self::$returnDateType = $returnDateType; self::$returnDateType = $returnDateType;
@ -128,8 +131,8 @@ class Functions
* *
* @return string Return Date Format * @return string Return Date Format
* Possible Return values are: * Possible Return values are:
* Functions::RETURNDATE_PHP_NUMERIC 'P' * Functions::RETURNDATE_UNIX_TIMESTAMP 'P'
* Functions::RETURNDATE_PHP_OBJECT 'O' * Functions::RETURNDATE_PHP_DATETIME_OBJECT 'O'
* Functions::RETURNDATE_EXCEL 'E' * Functions::RETURNDATE_EXCEL 'E'
*/ */
public static function getReturnDateType() public static function getReturnDateType()

View File

@ -1,503 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
/**
* Class DateTimeTest.
*/
class DateTimeTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
/**
* @dataProvider providerDATE
*
* @param mixed $expectedResult
*/
public function testDATE($expectedResult, ...$args)
{
$result = DateTime::DATE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerDATE()
{
return require 'data/Calculation/DateTime/DATE.php';
}
public function testDATEtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::DATE(2012, 1, 31);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(1327968000, $result, null, 1E-8);
}
public function testDATEtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::DATE(2012, 1, 31);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('d-M-Y'), '31-Jan-2012');
}
public function testDATEwith1904Calendar()
{
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
$result = DateTime::DATE(1918, 11, 11);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
self::assertEquals($result, 5428);
}
public function testDATEwith1904CalendarError()
{
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
$result = DateTime::DATE(1901, 1, 31);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
self::assertEquals($result, '#NUM!');
}
/**
* @dataProvider providerDATEVALUE
*
* @param mixed $expectedResult
*/
public function testDATEVALUE($expectedResult, ...$args)
{
$result = DateTime::DATEVALUE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerDATEVALUE()
{
return require 'data/Calculation/DateTime/DATEVALUE.php';
}
public function testDATEVALUEtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::DATEVALUE('2012-1-31');
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(1327968000, $result, null, 1E-8);
}
public function testDATEVALUEtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::DATEVALUE('2012-1-31');
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('d-M-Y'), '31-Jan-2012');
}
/**
* @dataProvider providerYEAR
*
* @param mixed $expectedResult
*/
public function testYEAR($expectedResult, ...$args)
{
$result = DateTime::YEAR(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerYEAR()
{
return require 'data/Calculation/DateTime/YEAR.php';
}
/**
* @dataProvider providerMONTH
*
* @param mixed $expectedResult
*/
public function testMONTH($expectedResult, ...$args)
{
$result = DateTime::MONTHOFYEAR(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerMONTH()
{
return require 'data/Calculation/DateTime/MONTH.php';
}
/**
* @dataProvider providerWEEKNUM
*
* @param mixed $expectedResult
*/
public function testWEEKNUM($expectedResult, ...$args)
{
$result = DateTime::WEEKNUM(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerWEEKNUM()
{
return require 'data/Calculation/DateTime/WEEKNUM.php';
}
/**
* @dataProvider providerISOWEEKNUM
*
* @param mixed $expectedResult
* @param mixed $dateValue
*/
public function testISOWEEKNUM($expectedResult, $dateValue)
{
$result = DateTime::ISOWEEKNUM($dateValue);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerISOWEEKNUM()
{
return require 'data/Calculation/DateTime/ISOWEEKNUM.php';
}
/**
* @dataProvider providerWEEKDAY
*
* @param mixed $expectedResult
*/
public function testWEEKDAY($expectedResult, ...$args)
{
$result = DateTime::WEEKDAY(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerWEEKDAY()
{
return require 'data/Calculation/DateTime/WEEKDAY.php';
}
/**
* @dataProvider providerDAY
*
* @param mixed $expectedResultExcel
* @param mixed $expectedResultOpenOffice
*/
public function testDAY($expectedResultExcel, $expectedResultOpenOffice, ...$args)
{
$resultExcel = DateTime::DAYOFMONTH(...$args);
self::assertEquals($expectedResultExcel, $resultExcel, null, 1E-8);
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
$resultOpenOffice = DateTime::DAYOFMONTH(...$args);
self::assertEquals($expectedResultOpenOffice, $resultOpenOffice, null, 1E-8);
}
public function providerDAY()
{
return require 'data/Calculation/DateTime/DAY.php';
}
/**
* @dataProvider providerTIME
*
* @param mixed $expectedResult
*/
public function testTIME($expectedResult, ...$args)
{
$result = DateTime::TIME(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerTIME()
{
return require 'data/Calculation/DateTime/TIME.php';
}
public function testTIMEtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::TIME(7, 30, 20);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(27020, $result, null, 1E-8);
}
public function testTIMEtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::TIME(7, 30, 20);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('H:i:s'), '07:30:20');
}
/**
* @dataProvider providerTIMEVALUE
*
* @param mixed $expectedResult
*/
public function testTIMEVALUE($expectedResult, ...$args)
{
$result = DateTime::TIMEVALUE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerTIMEVALUE()
{
return require 'data/Calculation/DateTime/TIMEVALUE.php';
}
public function testTIMEVALUEtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::TIMEVALUE('7:30:20');
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(23420, $result, null, 1E-8);
}
public function testTIMEVALUEtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::TIMEVALUE('7:30:20');
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('H:i:s'), '07:30:20');
}
/**
* @dataProvider providerHOUR
*
* @param mixed $expectedResult
*/
public function testHOUR($expectedResult, ...$args)
{
$result = DateTime::HOUROFDAY(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerHOUR()
{
return require 'data/Calculation/DateTime/HOUR.php';
}
/**
* @dataProvider providerMINUTE
*
* @param mixed $expectedResult
*/
public function testMINUTE($expectedResult, ...$args)
{
$result = DateTime::MINUTE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerMINUTE()
{
return require 'data/Calculation/DateTime/MINUTE.php';
}
/**
* @dataProvider providerSECOND
*
* @param mixed $expectedResult
*/
public function testSECOND($expectedResult, ...$args)
{
$result = DateTime::SECOND(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerSECOND()
{
return require 'data/Calculation/DateTime/SECOND.php';
}
/**
* @dataProvider providerNETWORKDAYS
*
* @param mixed $expectedResult
*/
public function testNETWORKDAYS($expectedResult, ...$args)
{
$result = DateTime::NETWORKDAYS(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerNETWORKDAYS()
{
return require 'data/Calculation/DateTime/NETWORKDAYS.php';
}
/**
* @dataProvider providerWORKDAY
*
* @param mixed $expectedResult
*/
public function testWORKDAY($expectedResult, ...$args)
{
$result = DateTime::WORKDAY(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerWORKDAY()
{
return require 'data/Calculation/DateTime/WORKDAY.php';
}
/**
* @dataProvider providerEDATE
*
* @param mixed $expectedResult
*/
public function testEDATE($expectedResult, ...$args)
{
$result = DateTime::EDATE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerEDATE()
{
return require 'data/Calculation/DateTime/EDATE.php';
}
public function testEDATEtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::EDATE('2012-1-26', -1);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(1324857600, $result, null, 1E-8);
}
public function testEDATEtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::EDATE('2012-1-26', -1);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('d-M-Y'), '26-Dec-2011');
}
/**
* @dataProvider providerEOMONTH
*
* @param mixed $expectedResult
*/
public function testEOMONTH($expectedResult, ...$args)
{
$result = DateTime::EOMONTH(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerEOMONTH()
{
return require 'data/Calculation/DateTime/EOMONTH.php';
}
public function testEOMONTHtoPHP()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::EOMONTH('2012-1-26', -1);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
self::assertEquals(1325289600, $result, null, 1E-8);
}
public function testEOMONTHtoPHPObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::EOMONTH('2012-1-26', -1);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
// Must return an object...
self::assertInternalType('object', $result);
// ... of the correct type
self::assertTrue(is_a($result, 'DateTime'));
// ... with the correct value
self::assertEquals($result->format('d-M-Y'), '31-Dec-2011');
}
/**
* @dataProvider providerDATEDIF
*
* @param mixed $expectedResult
*/
public function testDATEDIF($expectedResult, ...$args)
{
$result = DateTime::DATEDIF(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerDATEDIF()
{
return require 'data/Calculation/DateTime/DATEDIF.php';
}
/**
* @dataProvider providerDAYS
*
* @param mixed $expectedResult
*/
public function testDAYS($expectedResult, ...$args)
{
$result = DateTime::DAYS(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerDAYS()
{
return require 'data/Calculation/DateTime/DAYS.php';
}
/**
* @dataProvider providerDAYS360
*
* @param mixed $expectedResult
*/
public function testDAYS360($expectedResult, ...$args)
{
$result = DateTime::DAYS360(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerDAYS360()
{
return require 'data/Calculation/DateTime/DAYS360.php';
}
/**
* @dataProvider providerYEARFRAC
*
* @param mixed $expectedResult
*/
public function testYEARFRAC($expectedResult, ...$args)
{
$result = DateTime::YEARFRAC(...$args);
self::assertEquals($expectedResult, $result, null, 1E-8);
}
public function providerYEARFRAC()
{
return require 'data/Calculation/DateTime/YEARFRAC.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class DateDifTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDATEDIF
*
* @param mixed $expectedResult
*/
public function testDATEDIF($expectedResult, ...$args)
{
$result = DateTime::DATEDIF(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerDATEDIF()
{
return require 'data/Calculation/DateTime/DATEDIF.php';
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class DateTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDATE
*
* @param mixed $expectedResult
*/
public function testDATE($expectedResult, ...$args)
{
$result = DateTime::DATE(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerDATE()
{
return require 'data/Calculation/DateTime/DATE.php';
}
public function testDATEtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP);
$result = DateTime::DATE(2012, 1, 31);
$this->assertEquals(1327968000, $result, '', 1E-8);
}
public function testDATEtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT);
$result = DateTime::DATE(2012, 1, 31);
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'), '31-Jan-2012');
}
public function testDATEwith1904Calendar()
{
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
$result = DateTime::DATE(1918, 11, 11);
$this->assertEquals($result, 5428);
}
public function testDATEwith1904CalendarError()
{
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
$result = DateTime::DATE(1901, 1, 31);
$this->assertEquals($result, '#NUM!');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class DateValueTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDATEVALUE
*
* @param mixed $expectedResult
*/
public function testDATEVALUE($expectedResult, ...$args)
{
$result = DateTime::DATEVALUE(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerDATEVALUE()
{
return require 'data/Calculation/DateTime/DATEVALUE.php';
}
public function testDATEVALUEtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP);
$result = DateTime::DATEVALUE('2012-1-31');
$this->assertEquals(1327968000, $result, '', 1E-8);
}
public function testDATEVALUEtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT);
$result = DateTime::DATEVALUE('2012-1-31');
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'), '31-Jan-2012');
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class DayTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDAY
*
* @param mixed $expectedResultExcel
* @param mixed $expectedResultOpenOffice
*/
public function testDAY($expectedResultExcel, $expectedResultOpenOffice, ...$args)
{
$resultExcel = DateTime::DAYOFMONTH(...$args);
$this->assertEquals($expectedResultExcel, $resultExcel, '', 1E-8);
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
$resultOpenOffice = DateTime::DAYOFMONTH(...$args);
$this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, '', 1E-8);
}
public function providerDAY()
{
return require 'data/Calculation/DateTime/DAY.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class Days360Test extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDAYS360
*
* @param mixed $expectedResult
*/
public function testDAYS360($expectedResult, ...$args)
{
$result = DateTime::DAYS360(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerDAYS360()
{
return require 'data/Calculation/DateTime/DAYS360.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class DaysTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerDAYS
*
* @param mixed $expectedResult
*/
public function testDAYS($expectedResult, ...$args)
{
$result = DateTime::DAYS(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerDAYS()
{
return require 'data/Calculation/DateTime/DAYS.php';
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class EDateTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerEDATE
*
* @param mixed $expectedResult
*/
public function testEDATE($expectedResult, ...$args)
{
$result = DateTime::EDATE(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerEDATE()
{
return require 'data/Calculation/DateTime/EDATE.php';
}
public function testEDATEtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP);
$result = DateTime::EDATE('2012-1-26', -1);
$this->assertEquals(1324857600, $result, '', 1E-8);
}
public function testEDATEtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT);
$result = DateTime::EDATE('2012-1-26', -1);
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'), '26-Dec-2011');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class EoMonthTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerEOMONTH
*
* @param mixed $expectedResult
*/
public function testEOMONTH($expectedResult, ...$args)
{
$result = DateTime::EOMONTH(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerEOMONTH()
{
return require 'data/Calculation/DateTime/EOMONTH.php';
}
public function testEOMONTHtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP);
$result = DateTime::EOMONTH('2012-1-26', -1);
$this->assertEquals(1325289600, $result, '', 1E-8);
}
public function testEOMONTHtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT);
$result = DateTime::EOMONTH('2012-1-26', -1);
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('d-M-Y'), '31-Dec-2011');
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class HourTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerHOUR
*
* @param mixed $expectedResult
*/
public function testHOUR($expectedResult, ...$args)
{
$result = DateTime::HOUROFDAY(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerHOUR()
{
return require 'data/Calculation/DateTime/HOUR.php';
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class IsoWeekNumTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerISOWEEKNUM
*
* @param mixed $expectedResult
* @param mixed $dateValue
*/
public function testISOWEEKNUM($expectedResult, $dateValue)
{
$result = DateTime::ISOWEEKNUM($dateValue);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerISOWEEKNUM()
{
return require 'data/Calculation/DateTime/ISOWEEKNUM.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class MinuteTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerMINUTE
*
* @param mixed $expectedResult
*/
public function testMINUTE($expectedResult, ...$args)
{
$result = DateTime::MINUTE(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerMINUTE()
{
return require 'data/Calculation/DateTime/MINUTE.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class MonthTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerMONTH
*
* @param mixed $expectedResult
*/
public function testMONTH($expectedResult, ...$args)
{
$result = DateTime::MONTHOFYEAR(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerMONTH()
{
return require 'data/Calculation/DateTime/MONTH.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class NetworkDaysTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerNETWORKDAYS
*
* @param mixed $expectedResult
*/
public function testNETWORKDAYS($expectedResult, ...$args)
{
$result = DateTime::NETWORKDAYS(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerNETWORKDAYS()
{
return require 'data/Calculation/DateTime/NETWORKDAYS.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class SecondTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerSECOND
*
* @param mixed $expectedResult
*/
public function testSECOND($expectedResult, ...$args)
{
$result = DateTime::SECOND(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerSECOND()
{
return require 'data/Calculation/DateTime/SECOND.php';
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class TimeTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerTIME
*
* @param mixed $expectedResult
*/
public function testTIME($expectedResult, ...$args)
{
$result = DateTime::TIME(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerTIME()
{
return require 'data/Calculation/DateTime/TIME.php';
}
public function testTIMEtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
$result = DateTime::TIME(7, 30, 20);
$this->assertEquals(27020, $result, '', 1E-8);
}
public function testTIMEtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
$result = DateTime::TIME(7, 30, 20);
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'), '07:30:20');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class TimeValueTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerTIMEVALUE
*
* @param mixed $expectedResult
*/
public function testTIMEVALUE($expectedResult, ...$args)
{
$result = DateTime::TIMEVALUE(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerTIMEVALUE()
{
return require 'data/Calculation/DateTime/TIMEVALUE.php';
}
public function testTIMEVALUEtoUnixTimestamp()
{
Functions::setReturnDateType(Functions::RETURNDATE_UNIX_TIMESTAMP);
$result = DateTime::TIMEVALUE('7:30:20');
$this->assertEquals(23420, $result, '', 1E-8);
}
public function testTIMEVALUEtoDateTimeObject()
{
Functions::setReturnDateType(Functions::RETURNDATE_PHP_DATETIME_OBJECT);
$result = DateTime::TIMEVALUE('7:30:20');
// Must return an object...
$this->assertInternalType('object', $result);
// ... of the correct type
$this->assertTrue(is_a($result, 'DateTimeInterface'));
// ... with the correct value
$this->assertEquals($result->format('H:i:s'), '07:30:20');
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class WeekDayTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerWEEKDAY
*
* @param mixed $expectedResult
*/
public function testWEEKDAY($expectedResult, ...$args)
{
$result = DateTime::WEEKDAY(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerWEEKDAY()
{
return require 'data/Calculation/DateTime/WEEKDAY.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class WeekNumTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerWEEKNUM
*
* @param mixed $expectedResult
*/
public function testWEEKNUM($expectedResult, ...$args)
{
$result = DateTime::WEEKNUM(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerWEEKNUM()
{
return require 'data/Calculation/DateTime/WEEKNUM.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class WorkDayTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerWORKDAY
*
* @param mixed $expectedResult
*/
public function testWORKDAY($expectedResult, ...$args)
{
$result = DateTime::WORKDAY(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerWORKDAY()
{
return require 'data/Calculation/DateTime/WORKDAY.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class YearFracTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerYEARFRAC
*
* @param mixed $expectedResult
*/
public function testYEARFRAC($expectedResult, ...$args)
{
$result = DateTime::YEARFRAC(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerYEARFRAC()
{
return require 'data/Calculation/DateTime/YEARFRAC.php';
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PHPUnit\Framework\TestCase;
class YearTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
}
/**
* @dataProvider providerYEAR
*
* @param mixed $expectedResult
*/
public function testYEAR($expectedResult, ...$args)
{
$result = DateTime::YEAR(...$args);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerYEAR()
{
return require 'data/Calculation/DateTime/YEAR.php';
}
}

View File

@ -21,7 +21,7 @@ class AveDevTest extends TestCase
public function testAVEDEV($expectedResult, ...$args) public function testAVEDEV($expectedResult, ...$args)
{ {
$result = Statistical::AVEDEV(...$args); $result = Statistical::AVEDEV(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerAVEDEV() public function providerAVEDEV()

View File

@ -21,7 +21,7 @@ class AverageATest extends TestCase
public function testAVERAGEA($expectedResult, ...$args) public function testAVERAGEA($expectedResult, ...$args)
{ {
$result = Statistical::AVERAGEA(...$args); $result = Statistical::AVERAGEA(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerAVERAGEA() public function providerAVERAGEA()

View File

@ -21,7 +21,7 @@ class AverageIfTest extends TestCase
public function testAVERAGEIF($expectedResult, ...$args) public function testAVERAGEIF($expectedResult, ...$args)
{ {
$result = Statistical::AVERAGEIF(...$args); $result = Statistical::AVERAGEIF(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerAVERAGEIF() public function providerAVERAGEIF()

View File

@ -21,7 +21,7 @@ class AverageTest extends TestCase
public function testAVERAGE($expectedResult, ...$args) public function testAVERAGE($expectedResult, ...$args)
{ {
$result = Statistical::AVERAGE(...$args); $result = Statistical::AVERAGE(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerAVERAGE() public function providerAVERAGE()

View File

@ -21,7 +21,7 @@ class BetaDistTest extends TestCase
public function testBETADIST($expectedResult, ...$args) public function testBETADIST($expectedResult, ...$args)
{ {
$result = Statistical::BETADIST(...$args); $result = Statistical::BETADIST(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerBETADIST() public function providerBETADIST()

View File

@ -21,7 +21,7 @@ class BetaInvTest extends TestCase
public function testBETAINV($expectedResult, ...$args) public function testBETAINV($expectedResult, ...$args)
{ {
$result = Statistical::BETAINV(...$args); $result = Statistical::BETAINV(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerBETAINV() public function providerBETAINV()

View File

@ -21,7 +21,7 @@ class BinomDistTest extends TestCase
public function testBINOMDIST($expectedResult, ...$args) public function testBINOMDIST($expectedResult, ...$args)
{ {
$result = Statistical::BINOMDIST(...$args); $result = Statistical::BINOMDIST(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerBINOMDIST() public function providerBINOMDIST()

View File

@ -21,7 +21,7 @@ class ChiDistTest extends TestCase
public function testCHIDIST($expectedResult, ...$args) public function testCHIDIST($expectedResult, ...$args)
{ {
$result = Statistical::CHIDIST(...$args); $result = Statistical::CHIDIST(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCHIDIST() public function providerCHIDIST()

View File

@ -21,7 +21,7 @@ class ChiInvTest extends TestCase
public function testCHIINV($expectedResult, ...$args) public function testCHIINV($expectedResult, ...$args)
{ {
$result = Statistical::CHIINV(...$args); $result = Statistical::CHIINV(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCHIINV() public function providerCHIINV()

View File

@ -21,7 +21,7 @@ class ConfidenceTest extends TestCase
public function testCONFIDENCE($expectedResult, ...$args) public function testCONFIDENCE($expectedResult, ...$args)
{ {
$result = Statistical::CONFIDENCE(...$args); $result = Statistical::CONFIDENCE(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCONFIDENCE() public function providerCONFIDENCE()

View File

@ -21,7 +21,7 @@ class CorrelTest extends TestCase
public function testCORREL($expectedResult, array $xargs, array $yargs) public function testCORREL($expectedResult, array $xargs, array $yargs)
{ {
$result = Statistical::CORREL($xargs, $yargs); $result = Statistical::CORREL($xargs, $yargs);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCORREL() public function providerCORREL()

View File

@ -21,7 +21,7 @@ class CountATest extends TestCase
public function testCOUNTA($expectedResult, ...$args) public function testCOUNTA($expectedResult, ...$args)
{ {
$result = Statistical::COUNTA(...$args); $result = Statistical::COUNTA(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCOUNTA() public function providerCOUNTA()

View File

@ -21,7 +21,7 @@ class CountBlankTest extends TestCase
public function testCOUNTBLANK($expectedResult, ...$args) public function testCOUNTBLANK($expectedResult, ...$args)
{ {
$result = Statistical::COUNTBLANK(...$args); $result = Statistical::COUNTBLANK(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCOUNTBLANK() public function providerCOUNTBLANK()

View File

@ -21,7 +21,7 @@ class CountIfTest extends TestCase
public function testCOUNTIF($expectedResult, ...$args) public function testCOUNTIF($expectedResult, ...$args)
{ {
$result = Statistical::COUNTIF(...$args); $result = Statistical::COUNTIF(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCOUNTIF() public function providerCOUNTIF()

View File

@ -21,7 +21,7 @@ class CountIfsTest extends TestCase
public function testCOUNTIFS($expectedResult, ...$args) public function testCOUNTIFS($expectedResult, ...$args)
{ {
$result = Statistical::COUNTIFS(...$args); $result = Statistical::COUNTIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCOUNTIFS() public function providerCOUNTIFS()

View File

@ -21,7 +21,7 @@ class CountTest extends TestCase
public function testBasicCOUNT($expectedResult, ...$args) public function testBasicCOUNT($expectedResult, ...$args)
{ {
$result = Statistical::COUNT(...$args); $result = Statistical::COUNT(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerBasicCOUNT() public function providerBasicCOUNT()
@ -37,7 +37,7 @@ class CountTest extends TestCase
public function testExcelCOUNT($expectedResult, ...$args) public function testExcelCOUNT($expectedResult, ...$args)
{ {
$result = Statistical::COUNT(...$args); $result = Statistical::COUNT(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerExcelCOUNT() public function providerExcelCOUNT()
@ -55,7 +55,7 @@ class CountTest extends TestCase
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
$result = Statistical::COUNT(...$args); $result = Statistical::COUNT(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerOpenOfficeCOUNT() public function providerOpenOfficeCOUNT()
@ -73,7 +73,7 @@ class CountTest extends TestCase
Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC);
$result = Statistical::COUNT(...$args); $result = Statistical::COUNT(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerGnumericCOUNT() public function providerGnumericCOUNT()

View File

@ -21,7 +21,7 @@ class CovarTest extends TestCase
public function testCOVAR($expectedResult, ...$args) public function testCOVAR($expectedResult, ...$args)
{ {
$result = Statistical::COVAR(...$args); $result = Statistical::COVAR(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerCOVAR() public function providerCOVAR()

View File

@ -21,7 +21,7 @@ class ForecastTest extends TestCase
public function testFORECAST($expectedResult, ...$args) public function testFORECAST($expectedResult, ...$args)
{ {
$result = Statistical::FORECAST(...$args); $result = Statistical::FORECAST(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerFORECAST() public function providerFORECAST()

View File

@ -21,7 +21,7 @@ class InterceptTest extends TestCase
public function testINTERCEPT($expectedResult, array $xargs, array $yargs) public function testINTERCEPT($expectedResult, array $xargs, array $yargs)
{ {
$result = Statistical::INTERCEPT($xargs, $yargs); $result = Statistical::INTERCEPT($xargs, $yargs);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerINTERCEPT() public function providerINTERCEPT()

View File

@ -21,7 +21,7 @@ class MaxIfsTest extends TestCase
public function testMAXIFS($expectedResult, ...$args) public function testMAXIFS($expectedResult, ...$args)
{ {
$result = Statistical::MAXIFS(...$args); $result = Statistical::MAXIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerMAXIFS() public function providerMAXIFS()

View File

@ -21,7 +21,7 @@ class MinIfsTest extends TestCase
public function testMINIFS($expectedResult, ...$args) public function testMINIFS($expectedResult, ...$args)
{ {
$result = Statistical::MINIFS(...$args); $result = Statistical::MINIFS(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerMINIFS() public function providerMINIFS()

View File

@ -21,7 +21,7 @@ class PermutTest extends TestCase
public function testPERMUT($expectedResult, ...$args) public function testPERMUT($expectedResult, ...$args)
{ {
$result = Statistical::PERMUT(...$args); $result = Statistical::PERMUT(...$args);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerPERMUT() public function providerPERMUT()

View File

@ -21,7 +21,7 @@ class RsqTest extends TestCase
public function testRSQ($expectedResult, array $xargs, array $yargs) public function testRSQ($expectedResult, array $xargs, array $yargs)
{ {
$result = Statistical::RSQ($xargs, $yargs); $result = Statistical::RSQ($xargs, $yargs);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerRSQ() public function providerRSQ()

View File

@ -21,7 +21,7 @@ class SlopeTest extends TestCase
public function testSLOPE($expectedResult, array $xargs, array $yargs) public function testSLOPE($expectedResult, array $xargs, array $yargs)
{ {
$result = Statistical::SLOPE($xargs, $yargs); $result = Statistical::SLOPE($xargs, $yargs);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerSLOPE() public function providerSLOPE()

View File

@ -21,7 +21,7 @@ class SteyxTest extends TestCase
public function testSTEYX($expectedResult, array $xargs, array $yargs) public function testSTEYX($expectedResult, array $xargs, array $yargs)
{ {
$result = Statistical::STEYX($xargs, $yargs); $result = Statistical::STEYX($xargs, $yargs);
self::assertEquals($expectedResult, $result, '', 1E-12); $this->assertEquals($expectedResult, $result, '', 1E-12);
} }
public function providerSTEYX() public function providerSTEYX()

View File

@ -5,485 +5,329 @@
return [ return [
[ [
6890, 6890,
18, 18, 11, 11,
11,
11,
], ],
// Excel 1900 Calendar Base Date // Excel 1900 Calendar Base Date
[ [
1, 1,
1900, 1900, 1, 1,
1,
1,
], ],
// Day before Excel mythical 1900 leap day // Day before Excel mythical 1900 leap day
[ [
59, 59,
1900, 1900, 2, 28,
2,
28,
], ],
// Excel mythical 1900 leap day // Excel mythical 1900 leap day
[ [
60, 60,
1900, 1900, 2, 29,
2,
29,
], ],
// Day after Excel mythical 1900 leap day
[ [
// Day after Excel mythical 1900 leap day
61, 61,
1900, 1900, 3, 1,
3,
1,
], ],
// Day after Excel mythical 1900 leap day // Day after Excel actual 1904 leap day
[ [
713, 713,
1901, 1901, 12, 13,
12,
13,
], ],
// PHP 32-bit Earliest Date // PHP 32-bit Earliest Date (unix timestamp)
[ [
714, 714,
1901, 1901, 12, 14,
12,
14,
], ],
[ [
1461, 1461,
1903, 1903, 12, 31,
12,
31,
], ],
// Excel 1904 Calendar Base Date // Excel 1904 Calendar Base Date
[ [
1462, 1462,
1904, 1904, 1, 1,
1,
1,
], ],
[ [
1463, 1463,
1904, 1904, 1, 2,
1,
2,
], ],
[ [
22269, 22269,
1960, 1960, 12, 19,
12,
19,
], ],
// PHP Base Date // PHP (unix timestamp) Base Date
[ [
25569, 25569,
1970, 1970, 1, 1,
1,
1,
], ],
[ [
30292, 30292,
1982, 1982, 12, 7,
12,
7,
], ],
[ [
39611, 39611,
2008, 2008, 6, 12,
6,
12,
], ],
// PHP 32-bit Latest Date // PHP (unix timestamp) 32-bit Latest Date
[ [
50424, 50424,
2038, 2038, 1, 19,
1,
19,
], ],
// Day after PHP 32-bit Latest Date // Day after PHP (unix timestamp) 32-bit Latest Date
[ [
50425, 50425,
2038, 2038, 1, 20,
1,
20,
], ],
[ [
39448, 39448,
2008, 2008, 1, 1,
1,
1,
], ],
[ [
39447, 39447,
2008, 2008, 1, null,
1,
null,
], ],
[ [
39446, 39446,
2008, 2008, 1, -1,
1,
-1,
], ],
[ [
39417, 39417,
2008, 2008, 1, -30,
1,
-30,
], ],
[ [
39416, 39416,
2008, 2008, 1, -31,
1,
-31,
], ],
[ [
39082, 39082,
2008, 2008, 1, -365,
1,
-365,
], ],
[ [
39508, 39508,
2008, 2008, 3, 1,
3,
1,
], ],
[ [
39507, 39507,
2008, 2008, 3, null,
3,
null,
], ],
[ [
39506, 39506,
2008, 2008, 3, -1,
3,
-1,
], ],
[ [
39142, 39142,
2008, 2008, 3, -365,
3,
-365,
], ],
[ [
39417, 39417,
2008, 2008, null, 1,
null,
1,
], ],
[ [
39387, 39387,
2008, 2008, -1, 1,
-1,
1,
], ],
[ [
39083, 39083,
2008, 2008, -11, 1,
-11,
1,
], ],
[ [
39052, 39052,
2008, 2008, -12, 1,
-12,
1,
], ],
[ [
39022, 39022,
2008, 2008, -13, 1,
-13,
1,
], ],
[ [
39051, 39051,
2008, 2008, -13, 30,
-13,
30,
], ],
[ [
39021, 39021,
2008, 2008, -13, null,
-13,
null,
], ],
[ [
38991, 38991,
2008, 2008, -13, -30,
-13,
-30,
], ],
[ [
38990, 38990,
2008, 2008, -13, -31,
-13,
-31,
], ],
[ [
39814, 39814,
2008, 2008, 13, 1,
13,
1,
], ],
[ [
39507, 39507,
2007, 2007, 15, null,
15,
null,
], ],
[ [
40210, 40210,
2008, 2008, 26, 1,
26,
1,
], ],
[ [
40199, 40199,
2008, 2008, 26, -10,
26,
-10,
], ],
[ [
38686, 38686,
2008, 2008, -26, 61,
-26,
61,
], ],
[ [
39641, 39641,
2010, 2010, -15, -50,
-15,
-50,
], ],
[ [
39741, 39741,
2010, 2010, -15, 50,
-15,
50,
], ],
[ [
40552, 40552,
2010, 2010, 15, -50,
15,
-50,
], ],
[ [
40652, 40652,
2010, 2010, 15, 50,
15,
50,
], ],
[ [
40179, 40179,
2010, 2010, 1.5, 1,
1.5,
1,
], ],
[ [
40178, 40178,
2010, 2010, 1.5, 0,
1.5,
0,
], ],
[ [
40148, 40148,
2010, 2010, 0, 1.5,
0,
1.5,
], ],
[ [
40179, 40179,
2010, 2010, 1, 1.5,
1,
1.5,
], ],
[ [
41075, 41075,
2012, 2012, 6, 15,
6,
15,
], ],
[ [
41060, 41060,
2012, 2012, 6, null,
6,
null,
], ],
[ [
40892, 40892,
2012, 2012, null, 15,
null,
15,
], ],
[ [
167, 167,
null, null, 6, 15,
6,
15,
], ],
[ [
3819, 3819,
10, 10, 6, 15,
6,
15,
], ],
[ [
3622, 3622,
10, 10, null, null,
null,
null,
], ],
[ [
274, 274,
null, null, 10, null,
10,
null,
], ],
[ [
'#NUM!', '#NUM!',
null, null, null, 10,
null,
10,
], ],
[ [
'#NUM!', '#NUM!',
-20, -20, null, null,
null,
null,
], ],
[ [
'#NUM!', '#NUM!',
-20, -20, 6, 15,
6,
15,
], ],
// Excel Maximum Date // Excel Maximum Date
[ [
2958465, 2958465,
9999, 9999, 12, 31,
12,
31,
], ],
// Exceeded Excel Maximum Date // Exceeded Excel Maximum Date
[ [
'#NUM!', '#NUM!',
10000, 10000, 1, 1,
1,
1,
], ],
[ [
39670, 39670,
2008, 2008, 8, 10,
8,
10,
], ],
[ [
39813, 39813,
2008, 2008, 12, 31,
12,
31,
], ],
[ [
39692, 39692,
2008, 2008, 8, 32,
8,
32,
], ],
[ [
39844, 39844,
2008, 2008, 13, 31,
13,
31,
], ],
[ [
39813, 39813,
2009, 2009, 1, 0,
1,
0,
], ],
[ [
39812, 39812,
2009, 2009, 1, -1,
1,
-1,
], ],
[ [
39782, 39782,
2009, 2009, 0, 0,
0,
0,
], ],
[ [
39781, 39781,
2009, 2009, 0, -1,
0,
-1,
], ],
[ [
39752, 39752,
2009, 2009, -1, 0,
-1,
0,
], ],
[ [
39751, 39751,
2009, 2009, -1, -1,
-1,
-1,
], ],
[ [
40146, 40146,
2010, 2010, 0, -1,
0,
-1,
], ],
[ [
40329, 40329,
2010, 2010, 5, 31,
5,
31,
], ],
// MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date // MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date
[ [
40199, 40199,
2010, 2010, 1, '21st',
1,
'21st',
], ],
// MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date // MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date
[ [
40258, 40258,
2010, 2010, 'March', '21st',
'March',
'21st',
], ],
// MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date // MS Excel will fail with a #VALUE return, but PhpSpreadsheet can parse this date
[ [
40258, 40258,
2010, 2010, 'March', 21,
'March',
21,
], ],
[ [
'#VALUE!', '#VALUE!',
'ABC', 'ABC', 1, 21,
1,
21,
], ],
[ [
'#VALUE!', '#VALUE!',
2010, 2010, 'DEF', 21,
'DEF',
21,
], ],
[ [
'#VALUE!', '#VALUE!',
2010, 2010, 3, 'GHI',
3,
'GHI',
], ],
]; ];

View File

@ -4,28 +4,28 @@
return [ return [
[ [
19, // Result for Excel 19, // Result for Excel
19, // Result for OpenOffice 19, // Result for OpenOffice
22269, 22269,
], ],
[ [
1, // Result for Excel 1, // Result for Excel
1, // Result for OpenOffice 1, // Result for OpenOffice
30348, 30348,
], ],
[ [
10, // Result for Excel 10, // Result for Excel
10, // Result for OpenOffice 10, // Result for OpenOffice
30843, 30843,
], ],
[ [
11, // Result for Excel 11, // Result for Excel
11, // Result for OpenOffice 11, // Result for OpenOffice
'11-Nov-1918', '11-Nov-1918',
], ],
[ [
28, // Result for Excel 28, // Result for Excel
28, // Result for OpenOffice 28, // Result for OpenOffice
'28-Feb-1904', '28-Feb-1904',
], ],
[ [
@ -34,23 +34,23 @@ return [
'Invalid', 'Invalid',
], ],
[ [
'#NUM!', // Result for Excel '#NUM!', // Result for Excel
29, // Result for OpenOffice 29, // Result for OpenOffice
-1, -1,
], ],
[ [
1, // Result for Excel 1, // Result for Excel
31, // Result for OpenOffice 31, // Result for OpenOffice
1, 1,
], ],
[ [
0, // Result for Excel 0, // Result for Excel
30, // Result for OpenOffice 30, // Result for OpenOffice
0.5, 0.5,
], ],
[ [
0, // Result for Excel 0, // Result for Excel
30, // Result for OpenOffice 30, // Result for OpenOffice
0, 0,
], ],
]; ];

View File

@ -3,134 +3,90 @@
return [ return [
[ [
0.75776620370400005, 0.75776620370400005,
18, 18, 11, 11,
11,
11,
], ],
[ [
0.26047453703700002, 0.26047453703700002,
6, 6, 15, 5,
15,
5,
], ],
[ [
0.52094907407400004, 0.52094907407400004,
12, 12, 30, 10,
30,
10,
], ],
[ [
0.78153935185199996, 0.78153935185199996,
18, 18, 45, 25,
45,
25,
], ],
[ [
0.64780092592600003, 0.64780092592600003,
15, 15, 32, 50,
32,
50,
], ],
[ [
0.50070601851899998, 0.50070601851899998,
12, 12, null, 61,
null,
61,
], ],
[ [
0.45832175925899998, 0.45832175925899998,
11, 11, null, -1,
null,
-1,
], ],
[ [
0.41589120370400001, 0.41589120370400001,
10, 10, null, -67,
null,
-67,
], ],
[ [
0.58478009259300001, 0.58478009259300001,
13, 13, 62, 5,
62,
5,
], ],
[ [
0.31964120370400001, 0.31964120370400001,
9, 9, -80, 17,
-80,
17,
], ],
[ [
0.22083333333300001, 0.22083333333300001,
8, 8, -162, null,
-162,
null,
], ],
[ [
'#NUM!', '#NUM!',
2, 2, -120, -1,
-120,
-1,
], ],
[ [
0.0, 0.0,
2, 2, -120, null,
-120,
null,
], ],
[ [
1.1574074E-5, 1.1574074E-5,
2, 2, -120, 1,
-120,
1,
], ],
[ [
0.50071759259299997, 0.50071759259299997,
36, 36, 1, 2,
1,
2,
], ],
[ [
'#NUM!', '#NUM!',
-1, -1, 2, 3,
2,
3,
], ],
[ [
0.001030092593, 0.001030092593,
-1, -1, 61, 29,
61,
29,
], ],
[ [
0.0, 0.0,
-1, -1, 61, -60,
61,
-60,
], ],
[ [
'#VALUE!', '#VALUE!',
'A', 'A', null, null,
null,
null,
], ],
[ [
0.49930555555599998, 0.49930555555599998,
11, 11, 59, 0,
59,
0,
], ],
[ [
0.5, 0.5,
12, 12, 0, 0,
0,
0,
], ],
[ [
0.70011574074100003, 0.70011574074100003,
16, 16, 48, 10,
48,
10,
], ],
]; ];

View File

@ -7,13 +7,11 @@ return [
], ],
[ [
4, 4,
'24-Oct-1968', '24-Oct-1968', 2,
2,
], ],
[ [
3, 3,
'24-Oct-1968', '24-Oct-1968', 3,
3,
], ],
[ [
4, 4,
@ -21,13 +19,11 @@ return [
], ],
[ [
3, 3,
'2000-06-14', '2000-06-14', 2,
2,
], ],
[ [
2, 2,
'2000-06-14', '2000-06-14', 3,
3,
], ],
[ [
4, 4,
@ -35,13 +31,11 @@ return [
], ],
[ [
3, 3,
'1996-07-24', '1996-07-24', 2,
2,
], ],
[ [
2, 2,
'1996-07-24', '1996-07-24', 3,
3,
], ],
[ [
7, 7,
@ -49,13 +43,11 @@ return [
], ],
[ [
6, 6,
'1996-07-27', '1996-07-27', 2,
2,
], ],
[ [
5, 5,
'1996-07-27', '1996-07-27', 3,
3,
], ],
[ [
1, 1,
@ -63,13 +55,11 @@ return [
], ],
[ [
7, 7,
'1977-7-31', '1977-7-31', 2,
2,
], ],
[ [
6, 6,
'1977-7-31', '1977-7-31', 3,
3,
], ],
[ [
2, 2,
@ -77,18 +67,15 @@ return [
], ],
[ [
1, 1,
'1977-8-1', '1977-8-1', 2,
2,
], ],
[ [
0, 0,
'1977-8-1', '1977-8-1', 3,
3,
], ],
[ [
7, 7,
'1900-2-5', '1900-2-5', 2,
2,
], ],
[ [
4, 4,
@ -100,23 +87,19 @@ return [
], ],
[ [
5, 5,
38093, 38093, 2,
2,
], ],
[ [
4, 4,
38093, 38093, 3,
3,
], ],
[ [
'#VALUE!', '#VALUE!',
'3/7/1977', '3/7/1977', 'A',
'A',
], ],
[ [
'#NUM!', '#NUM!',
'3/7/1977', '3/7/1977', 0,
0,
], ],
[ [
'#VALUE!', '#VALUE!',