Minor bugfixes for date/time edge cases

This commit is contained in:
MarkBaker 2015-03-28 17:45:49 +00:00
parent d9cda3f287
commit caad6b1956
1 changed files with 15 additions and 5 deletions

View File

@ -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();