Handle General number format as non date (#221)
If the number format is set to General (id = 0), do no try to format the value as a date
This commit is contained in:
parent
e9cd7a397e
commit
5a7c2c1262
@ -171,11 +171,23 @@ class StyleHelper
|
||||
protected function doesNumFmtIdIndicateDate($numFmtId)
|
||||
{
|
||||
return (
|
||||
!$this->doesNumFmtIdIndicateGeneralFormat($numFmtId) &&
|
||||
(
|
||||
$this->isNumFmtIdBuiltInDateFormat($numFmtId) ||
|
||||
$this->isNumFmtIdCustomDateFormat($numFmtId)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $numFmtId
|
||||
* @return bool Whether the number format ID indicates the "General" format (0 by convention)
|
||||
*/
|
||||
protected function doesNumFmtIdIndicateGeneralFormat($numFmtId)
|
||||
{
|
||||
return ($numFmtId === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $numFmtId
|
||||
* @return bool Whether the number format ID indicates that the number is a timestamp
|
||||
|
@ -59,6 +59,16 @@ class StyleHelperTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($shouldFormatAsDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testShouldFormatNumericValueAsDateWithGeneralFormat()
|
||||
{
|
||||
$styleHelper = $this->getStyleHelperMock([[], ['applyNumberFormat' => true, 'numFmtId' => 0]]);
|
||||
$shouldFormatAsDate = $styleHelper->shouldFormatNumericValueAsDate(1);
|
||||
$this->assertFalse($shouldFormatAsDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user