Skip to content

Commit 2ac618f

Browse files
committed
Date 0000-01-01 is valid [Closes #402]
1 parent 1881fea commit 2ac618f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/Dibi/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ private function normalize(array &$row): void
489489
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
490490

491491
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
492-
if ($value && substr((string) $value, 0, 3) !== '000') { // '', null, false, '0000-00-00', ...
492+
if ($value && substr((string) $value, 0, 7) !== '0000-00') { // '', null, false, '0000-00-00', ...
493493
$value = new DateTime($value);
494494
$row[$key] = $format ? $value->format($format) : $value;
495495
} else {

src/Dibi/Row.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function asDateTime(string $key, string $format = null)
3737
{
3838
$time = $this[$key];
3939
if (!$time instanceof DateTime) {
40-
if (!$time || substr((string) $time, 0, 3) === '000') { // '', null, false, '0000-00-00', ...
40+
if (!$time || substr((string) $time, 0, 7) === '0000-00') { // '', null, false, '0000-00-00', ...
4141
return null;
4242
}
4343
$time = new DateTime($time);

0 commit comments

Comments
 (0)