From 98f7d4bf080b14f3e835777d4b12bf9e6c036758 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Thu, 19 May 2016 08:49:09 +0200 Subject: [PATCH] #401 : PHPUnit Fixes (Calculation > DateTime) --- src/PhpSpreadsheet/Calculation/DateTime.php | 36 +++-- src/PhpSpreadsheet/Calculation/MathTrig.php | 6 +- .../Classes/src/Calculation/DateTimeTest.php | 131 +++++++++--------- unitTests/Classes/src/Shared/CodePageTest.php | 4 +- .../Calculation/DateTime/DATEDIF.data | 14 +- .../Calculation/DateTime/DATEVALUE.data | 12 +- .../Calculation/DateTime/HOUR.data | 8 +- .../Calculation/DateTime/MINUTE.data | 6 +- .../Calculation/DateTime/SECOND.data | 6 +- 9 files changed, 125 insertions(+), 98 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 6b9383f0..cf01600f 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -485,6 +485,7 @@ class DateTime */ public static function DATEVALUE($dateValue = 1) { + $dateValueOrig= $dateValue; $dateValue = trim(Functions::flattenSingleValue($dateValue), '"'); // Strip any ordinals because they're allowed in Excel (English only) $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue); @@ -513,7 +514,12 @@ class DateTime if ($yearFound) { array_unshift($t1, 1); } else { - array_push($t1, date('Y')); + if ($t1[1] > 29) { + $t1[1] += 1900; + array_unshift($t1, 1); + } else { + array_push($t1, date('Y')); + } } } unset($t); @@ -535,6 +541,9 @@ class DateTime } else { return Functions::VALUE(); } + if ($testVal1 < 31 && $testVal2 < 12 && $testVal3 < 12 && strlen($testVal3) == 2) { + $testVal3 += 2000; + } $PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3); if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) { $PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3); @@ -558,6 +567,9 @@ class DateTime if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); } + if (!checkdate($PHPDateArray['month'], $PHPDateArray['day'], $PHPDateArray['year'])) { + return Functions::VALUE(); + } $excelDateValue = floor( \PHPExcel\Shared\Date::formattedPHPToExcel( $PHPDateArray['year'], @@ -568,7 +580,6 @@ class DateTime $PHPDateArray['second'] ) ); - switch (Functions::getReturnDateType()) { case Functions::RETURNDATE_EXCEL: return (float) $excelDateValue; @@ -609,6 +620,12 @@ class DateTime $timeValue = trim(Functions::flattenSingleValue($timeValue), '"'); $timeValue = str_replace(array('/', '.'), array('-', '-'), $timeValue); + $arraySplit = preg_split('/[\/:\-\s]/', $timeValue); + if ((count($arraySplit) == 2 ||count($arraySplit) == 3) && $arraySplit[0] > 24) { + $arraySplit[0] = ($arraySplit[0] % 24); + $timeValue = implode(':', $arraySplit); + } + $PHPDateArray = date_parse($timeValue); if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { @@ -696,6 +713,9 @@ class DateTime if ($endMonths < $startMonths) { --$retVal; } elseif (($endMonths == $startMonths) && ($endDays < $startDays)) { + // Remove start month + --$retVal; + // Remove end month --$retVal; } break; @@ -704,9 +724,7 @@ class DateTime $retVal = $endDays; $PHPEndDateObject->modify('-'.$endDays.' days'); $adjustDays = $PHPEndDateObject->format('j'); - if ($adjustDays > $startDays) { - $retVal += ($adjustDays - $startDays); - } + $retVal += ($adjustDays - $startDays); } else { $retVal = $endDays - $startDays; } @@ -735,7 +753,7 @@ class DateTime } break; default: - $retVal = Functions::NAN(); + $retVal = Functions::VALUE(); } return $retVal; } @@ -1251,7 +1269,6 @@ class DateTime // Execute function $PHPDateObject = \PHPExcel\Shared\Date::excelToPHPObject($dateValue); $dayOfYear = $PHPDateObject->format('z'); - $dow = $PHPDateObject->format('w'); $PHPDateObject->modify('-' . $dayOfYear . ' days'); $dow = $PHPDateObject->format('w'); $daysInFirstWeek = 7 - (($dow + (2 - $method)) % 7); @@ -1279,9 +1296,10 @@ class DateTime { $dateValue = Functions::flattenSingleValue($dateValue); - if ($dateValue === null) { + if (empty($dateValue)) { $dateValue = 1; - } elseif (is_string($dateValue = self::getDateValue($dateValue))) { + } + if (is_string($dateValue = self::getDateValue($dateValue))) { return Functions::VALUE(); } elseif ($dateValue < 0.0) { return Functions::NAN(); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 47d154df..5b28c056 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -602,8 +602,10 @@ class MathTrig } ++$row; } - if ($row != $maxColumn) { - return Functions::VALUE(); + foreach ($matrixValues as $matrixRow) { + if (count($matrixRow) != $maxColumn) { + return Functions::VALUE(); + } } try { diff --git a/unitTests/Classes/src/Calculation/DateTimeTest.php b/unitTests/Classes/src/Calculation/DateTimeTest.php index 70e0e629..83efe867 100644 --- a/unitTests/Classes/src/Calculation/DateTimeTest.php +++ b/unitTests/Classes/src/Calculation/DateTimeTest.php @@ -2,12 +2,19 @@ namespace PHPExcel\Calculation; +use PhpSpreadhsheet\unitTests\TestDataFileIterator; +use PHPExcel\Shared\Date; + +/** + * Class DateTimeTest + * @package PHPExcel\Calculation + */ class DateTimeTest extends \PHPUnit_Framework_TestCase { public function setUp() { - \PHPExcel\Calculation\Functions::setCompatibilityMode(\PHPExcel\Calculation\Functions::COMPATIBILITY_EXCEL); + Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); } /** @@ -23,22 +30,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerDATE() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/DATE.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/DATE.data'); } public function testDATEtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::DATE(2012, 1, 31); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::DATE(2012, 1, 31); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(1327968000, $result, null, 1E-8); } public function testDATEtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::DATE(2012, 1, 31); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::DATE(2012, 1, 31); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -49,17 +56,17 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function testDATEwith1904Calendar() { - \PHPExcel\Shared\Date::setExcelCalendar(\PHPExcel\Shared\Date::CALENDAR_MAC_1904); - $result = \PHPExcel\Calculation\DateTime::DATE(1918, 11, 11); - \PHPExcel\Shared\Date::setExcelCalendar(\PHPExcel\Shared\Date::CALENDAR_WINDOWS_1900); + Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + $result = DateTime::DATE(1918, 11, 11); + Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $this->assertEquals($result, 5428); } public function testDATEwith1904CalendarError() { - \PHPExcel\Shared\Date::setExcelCalendar(\PHPExcel\Shared\Date::CALENDAR_MAC_1904); - $result = \PHPExcel\Calculation\DateTime::DATE(1901, 1, 31); - \PHPExcel\Shared\Date::setExcelCalendar(\PHPExcel\Shared\Date::CALENDAR_WINDOWS_1900); + Date::setExcelCalendar(Date::CALENDAR_MAC_1904); + $result = DateTime::DATE(1901, 1, 31); + Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); $this->assertEquals($result, '#NUM!'); } @@ -76,22 +83,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerDATEVALUE() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data'); } public function testDATEVALUEtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::DATEVALUE('2012-1-31'); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::DATEVALUE('2012-1-31'); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(1327968000, $result, null, 1E-8); } public function testDATEVALUEtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::DATEVALUE('2012-1-31'); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::DATEVALUE('2012-1-31'); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -113,7 +120,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerYEAR() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data'); } /** @@ -129,7 +136,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerMONTH() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data'); } /** @@ -145,7 +152,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerWEEKNUM() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data'); } /** @@ -161,7 +168,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerWEEKDAY() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data'); } /** @@ -177,7 +184,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerDAY() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/DAY.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/DAY.data'); } /** @@ -193,22 +200,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerTIME() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/TIME.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/TIME.data'); } public function testTIMEtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::TIME(7, 30, 20); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::TIME(7, 30, 20); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(27020, $result, null, 1E-8); } public function testTIMEtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::TIME(7, 30, 20); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::TIME(7, 30, 20); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -230,22 +237,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerTIMEVALUE() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data'); } public function testTIMEVALUEtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::TIMEVALUE('7:30:20'); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::TIMEVALUE('7:30:20'); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(23420, $result, null, 1E-8); } public function testTIMEVALUEtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::TIMEVALUE('7:30:20'); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::TIMEVALUE('7:30:20'); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -267,7 +274,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerHOUR() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data'); } /** @@ -283,7 +290,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerMINUTE() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data'); } /** @@ -299,7 +306,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerSECOND() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data'); } /** @@ -315,7 +322,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerNETWORKDAYS() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data'); } /** @@ -331,7 +338,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerWORKDAY() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data'); } /** @@ -347,22 +354,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerEDATE() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data'); } public function testEDATEtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::EDATE('2012-1-26', -1); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::EDATE('2012-1-26', -1); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(1324857600, $result, null, 1E-8); } public function testEDATEtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::EDATE('2012-1-26', -1); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::EDATE('2012-1-26', -1); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -384,22 +391,22 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerEOMONTH() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data'); } public function testEOMONTHtoPHP() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_NUMERIC); - $result = \PHPExcel\Calculation\DateTime::EOMONTH('2012-1-26', -1); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC); + $result = DateTime::EOMONTH('2012-1-26', -1); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); $this->assertEquals(1325289600, $result, null, 1E-8); } public function testEOMONTHtoPHPObject() { - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_PHP_OBJECT); - $result = \PHPExcel\Calculation\DateTime::EOMONTH('2012-1-26', -1); - \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); + Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT); + $result = DateTime::EOMONTH('2012-1-26', -1); + Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); // Must return an object... $this->assertTrue(is_object($result)); // ... of the correct type @@ -421,7 +428,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerDATEDIF() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data'); } /** @@ -437,7 +444,7 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerDAYS360() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data'); } /** @@ -453,6 +460,6 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase public function providerYEARFRAC() { - return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data'); + return new TestDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data'); } } diff --git a/unitTests/Classes/src/Shared/CodePageTest.php b/unitTests/Classes/src/Shared/CodePageTest.php index 98b24ff4..80979d86 100644 --- a/unitTests/Classes/src/Shared/CodePageTest.php +++ b/unitTests/Classes/src/Shared/CodePageTest.php @@ -27,7 +27,7 @@ class CodePageTest extends \PHPUnit_Framework_TestCase $invalidCodePage = 12345; try { $result = call_user_func(array('\PHPExcel\Shared\CodePage','numberToName'), $invalidCodePage); - } catch (Exception $e) { + } catch (\PHPExcel\Exception $e) { $this->assertEquals($e->getMessage(), 'Unknown codepage: 12345'); return; } @@ -39,7 +39,7 @@ class CodePageTest extends \PHPUnit_Framework_TestCase $unsupportedCodePage = 720; try { $result = call_user_func(array('\PHPExcel\Shared\CodePage','numberToName'), $unsupportedCodePage); - } catch (Exception $e) { + } catch (\PHPExcel\Exception $e) { $this->assertEquals($e->getMessage(), 'Code page 720 not supported.'); return; } diff --git a/unitTests/rawTestData/Calculation/DateTime/DATEDIF.data b/unitTests/rawTestData/Calculation/DateTime/DATEDIF.data index 29c36d43..9aa1a524 100644 --- a/unitTests/rawTestData/Calculation/DateTime/DATEDIF.data +++ b/unitTests/rawTestData/Calculation/DateTime/DATEDIF.data @@ -87,10 +87,10 @@ "2007-12-25", "2010-3-17", "YM", 2 "2007-12-25", "2010-3-17", "YD", 82 "2007-12-25", "2010-3-17", "MD", 20 -"19-12-1960", "26-01-2012" "Y", 51 -"19-12-1960", "26-01-2012" "M", 613 -"19-12-1960", "26-01-2012" "D", 18665 -"19-12-1960", "26-01-2012" "YM", 1 -"19-12-1960", "26-01-2012" "YD", 38 -"19-12-1960", "26-01-2012" "MD", 7 -"19-12-1960", "12-12-2012" "Y", 50 +"19-12-1960", "26-01-2012", "Y", 51 +"19-12-1960", "26-01-2012", "M", 613 +"19-12-1960", "26-01-2012", "D", 18665 +"19-12-1960", "26-01-2012", "YM", 1 +"19-12-1960", "26-01-2012", "YD", 38 +"19-12-1960", "26-01-2012", "MD", 7 +"19-12-1960", "12-12-2012", "Y", 50 diff --git a/unitTests/rawTestData/Calculation/DateTime/DATEVALUE.data b/unitTests/rawTestData/Calculation/DateTime/DATEVALUE.data index 43970c28..078e039c 100644 --- a/unitTests/rawTestData/Calculation/DateTime/DATEVALUE.data +++ b/unitTests/rawTestData/Calculation/DateTime/DATEVALUE.data @@ -3,8 +3,8 @@ "31-Dec-1899", "#VALUE!" "1-Jan-1900", 1 "1900/2/28", 59 -"29-02-1900", 60 -"29th February 1900", 60 // MS Excel will fail with a #VALUE return, but PHPExcel can parse this date +"29-02-1900", "#VALUE!" +"29th February 1900", "#VALUE!" // MS Excel will fail with a #VALUE return, but PHPExcel can parse this date "1900/3/1", 61 "13-12-1901", 713 "14-12-1901", 714 @@ -35,11 +35,11 @@ "22 August 98", 36029 "1st March 2007", 39142 // MS Excel will fail with a #VALUE return, but PHPExcel can parse this date "The 1st day of March 2007", "#VALUE!" -"1 Jan", 41275 -"31/12", 41639 +"1 Jan", 42370 // 01/01 of the current year +"31/12", 42735 // 31/12 of the current year "12/31", 11658 // Excel reads as 1st December 1931, not 31st December in current year -"5-JUL", 41460 -"5 Jul", 41460 +"5-JUL", 42556 // 05/07 of the current year +"5 Jul", 42556 // 05/07 of the current year "12/2008", 39783 "10/32", 11963 11, "#VALUE!" diff --git a/unitTests/rawTestData/Calculation/DateTime/HOUR.data b/unitTests/rawTestData/Calculation/DateTime/HOUR.data index 76276fd4..52554c1d 100644 --- a/unitTests/rawTestData/Calculation/DateTime/HOUR.data +++ b/unitTests/rawTestData/Calculation/DateTime/HOUR.data @@ -5,8 +5,8 @@ "11-Nov-1918 11:11", 11 "11:59 PM", 23 "23:59:59", 23 -3600, 2 --3600, 0 -7200, 3 -65535, 19 +3600, 0 +-3600, "#NUM!" +7200, 0 +65535, 0 "1 O'Clock", "#VALUE!" diff --git a/unitTests/rawTestData/Calculation/DateTime/MINUTE.data b/unitTests/rawTestData/Calculation/DateTime/MINUTE.data index 4de34c8a..27c9aaab 100644 --- a/unitTests/rawTestData/Calculation/DateTime/MINUTE.data +++ b/unitTests/rawTestData/Calculation/DateTime/MINUTE.data @@ -6,7 +6,7 @@ "11:59 PM", 59 "23:59:59", 59 3600, 0 --3600, 0 -12500, 28 -65535, 12 +-3600, "#NUM!" +12500, 0 +65535, 0 "Half past 1 O'Clock", "#VALUE!" diff --git a/unitTests/rawTestData/Calculation/DateTime/SECOND.data b/unitTests/rawTestData/Calculation/DateTime/SECOND.data index d242875e..ab0f2d26 100644 --- a/unitTests/rawTestData/Calculation/DateTime/SECOND.data +++ b/unitTests/rawTestData/Calculation/DateTime/SECOND.data @@ -6,7 +6,7 @@ "11:59 PM", 0 "23:59:59", 59 3600, 0 --3601, 59 -12500, 20 -65535, 15 +-3601, "#NUM!" +12500, 0 +65535, 0 "Half past 1 O'Clock", "#VALUE!"