mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 14:46:50 +02:00
Result, Row: added support for datetime like 'Jun 17 2015 12:00:00:000AM' [Closes #180]
This commit is contained in:
@@ -515,7 +515,7 @@ class Result implements IDataSource
|
|||||||
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
|
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
|
||||||
|
|
||||||
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
|
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
|
||||||
if ((int) $value !== 0 || substr((string) $value, 0, 3) === '00:') { // '', NULL, FALSE, '0000-00-00', ...
|
if ($value && substr((string) $value, 0, 3) !== '000') { // '', NULL, FALSE, '0000-00-00', ...
|
||||||
$value = new DateTime($value);
|
$value = new DateTime($value);
|
||||||
$row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]);
|
$row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -38,7 +38,7 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
{
|
{
|
||||||
$time = $this[$key];
|
$time = $this[$key];
|
||||||
if (!$time instanceof DateTime) {
|
if (!$time instanceof DateTime) {
|
||||||
if ((int) $time === 0 && substr((string) $time, 0, 3) !== '00:') { // '', NULL, FALSE, '0000-00-00', ...
|
if (!$time || substr((string) $time, 0, 3) === '000') { // '', NULL, FALSE, '0000-00-00', ...
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
$time = new DateTime($time);
|
$time = new DateTime($time);
|
||||||
|
Reference in New Issue
Block a user