1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 01:48:05 +01:00

Date 0000-01-01 is valid [Closes #402]

This commit is contained in:
David Grudl 2021-11-24 18:11:42 +01:00
parent 1881fea0e5
commit 2ac618ffff
2 changed files with 2 additions and 2 deletions

View File

@ -489,7 +489,7 @@ class Result implements IDataSource
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
if ($value && substr((string) $value, 0, 3) !== '000') { // '', null, false, '0000-00-00', ...
if ($value && substr((string) $value, 0, 7) !== '0000-00') { // '', null, false, '0000-00-00', ...
$value = new DateTime($value);
$row[$key] = $format ? $value->format($format) : $value;
} else {

View File

@ -37,7 +37,7 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
{
$time = $this[$key];
if (!$time instanceof DateTime) {
if (!$time || substr((string) $time, 0, 3) === '000') { // '', null, false, '0000-00-00', ...
if (!$time || substr((string) $time, 0, 7) === '0000-00') { // '', null, false, '0000-00-00', ...
return null;
}
$time = new DateTime($time);