Permalink
Browse files

Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5.

Optionally use the new IntlDateFormatter::setTimeZone() method if it exists.
  • Loading branch information...
1 parent ef499c4 commit d2ea184488577051ad1153f51b992fdd7aabfbbf @LawnGnome LawnGnome committed Jan 10, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 Extension/Core/Type/DateType.php
@@ -263,7 +263,11 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId();
- $formatter->setTimezoneId(\DateTimeZone::UTC);
+ if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
+ $formatter->setTimeZone(\DateTimeZone::UTC);
+ } else {
+ $formatter->setTimeZoneId(\DateTimeZone::UTC);
+ }
if (preg_match($regex, $pattern, $matches)) {
$formatter->setPattern($matches[0]);
@@ -277,7 +281,11 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$formatter->setPattern($pattern);
}
- $formatter->setTimezoneId($timezone);
+ if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
+ $formatter->setTimeZone($timezone);
+ } else {
+ $formatter->setTimeZoneId($timezone);
+ }
return $timestamps;
}

0 comments on commit d2ea184

Please sign in to comment.