Datepicker can use an expressed date for default value

@Carbon::parse was still failing, wrapped in do nothing try/catch instead
We don't seem to need to prefix time values anymore, since DateTimeHelper::makeCarbon should handle it
Fixes #2299
This commit is contained in:
Samuel Georges 2016-08-13 11:29:01 +10:00
parent d7b9b4f65e
commit 1c3631bede
2 changed files with 7 additions and 9 deletions

View File

@ -89,14 +89,10 @@ class DatePicker extends FormWidgetBase
if ($value = $this->getLoadValue()) {
$value = $value instanceof Carbon ? $value->toDateTimeString() : $value;
/*
* Time
*/
if (strlen($value) <= 8) {
$value = Carbon::now()->toDateString() . ' ' . $value;
}
$value = DateTimeHelper::makeCarbon($value, false);
$value = $value instanceof Carbon ? $value->toDateTimeString() : $value;
}
/*

View File

@ -2,9 +2,9 @@
use Lang;
use Carbon\Carbon;
use Exception;
use DateTime as PhpDateTime;
use InvalidArgumentException;
use Exception;
class DateTime
{
@ -67,7 +67,9 @@ class DateTime
$value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
}
else {
$value = @Carbon::parse($value);
try {
$value = Carbon::parse($value);
} catch (Exception $ex) {}
}
if (!$value instanceof Carbon && $throwException) {