Skip to content

Commit

Permalink
Simply check for datetime / chronos object.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 6, 2016
1 parent 63ba09b commit 8acd94b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/View/Widget/DateTimeWidget.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
namespace CrudView\View\Widget;

use Cake\Chronos\ChronosInterface;
use Cake\Core\Configure;
use Cake\I18n\I18n;
use Cake\I18n\Time;
use Cake\View\Form\ContextInterface;
use DateTime;
use DateTimeInterface;

class DateTimeWidget extends \Cake\View\Widget\DateTimeWidget
{
Expand Down Expand Up @@ -40,7 +39,7 @@ public function render(array $data, ContextInterface $context)
$format = $this->_convertPHPToMomentFormat($data['data-format']);
}

if (!($val instanceof DateTime || $val instanceof ChronosInterface) && !empty($val)) {
if (!($val instanceof DateTimeInterface) && !empty($val)) {
$val = $type === 'date' ? Time::parseDate($val) : Time::parseDateTime($val);
}

Expand Down

0 comments on commit 8acd94b

Please sign in to comment.