From 2ac618ffff38a99ae6cd8b1880a103dd48145f09 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 24 Nov 2021 18:11:42 +0100 Subject: [PATCH] Date 0000-01-01 is valid [Closes #402] --- src/Dibi/Result.php | 2 +- src/Dibi/Row.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dibi/Result.php b/src/Dibi/Result.php index a84ef6f..6c2714c 100644 --- a/src/Dibi/Result.php +++ b/src/Dibi/Result.php @@ -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 { diff --git a/src/Dibi/Row.php b/src/Dibi/Row.php index eb82eec..78eae4d 100644 --- a/src/Dibi/Row.php +++ b/src/Dibi/Row.php @@ -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);