fixed the conversion of the special '0000-00-00 00:00' date

This commit is contained in:
Fabien Potencier
2014-01-05 00:37:22 +01:00
parent 27f3e0fc1e
commit 9b95570829
2 changed files with 9 additions and 5 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.15.1 (2013-XX-XX)
* fixed the conversion of the special '0000-00-00 00:00' date
* added an error message when trying to import an undefined block from a trait
* 1.15.0 (2013-12-06)
+8 -5
View File
@@ -504,15 +504,18 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
$defaultTimezone = $timezone;
}
// immutable dates
if ($date instanceof DateTimeImmutable) {
return false !== $timezone ? $date->setTimezone($defaultTimezone) : $date;
}
if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
$returningDate = new DateTime($date->format('c'));
$date = clone $date;
if (false !== $timezone) {
$returningDate->setTimezone($defaultTimezone);
} else {
$returningDate->setTimezone($date->getTimezone());
$date->setTimezone($defaultTimezone);
}
return $returningDate;
return $date;
}
$asString = (string) $date;