From caad6b1956b6b407baa3a2d0cca0caf5e2d09bfa Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sat, 28 Mar 2015 17:45:49 +0000 Subject: [PATCH] Minor bugfixes for date/time edge cases --- Classes/PHPExcel/Calculation/DateTime.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Classes/PHPExcel/Calculation/DateTime.php b/Classes/PHPExcel/Calculation/DateTime.php index 6eb96fd2..56c14079 100644 --- a/Classes/PHPExcel/Calculation/DateTime.php +++ b/Classes/PHPExcel/Calculation/DateTime.php @@ -1071,7 +1071,9 @@ class PHPExcel_Calculation_DateTime { public static function DAYOFMONTH($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue == 0.0) { return 0; @@ -1114,7 +1116,9 @@ class PHPExcel_Calculation_DateTime { } $style = floor($style); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1180,7 +1184,9 @@ class PHPExcel_Calculation_DateTime { } $method = floor($method); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1216,7 +1222,9 @@ class PHPExcel_Calculation_DateTime { public static function MONTHOFYEAR($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1245,7 +1253,9 @@ class PHPExcel_Calculation_DateTime { public static function YEAR($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN();