[Pkg-owncloud-commits] [php-sabre-vobject] 26/43: workaround depending on php version
David Prévot
taffit at moszumanska.debian.org
Fri Oct 10 14:16:16 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 1c33c56ff191eb51774de9469083023255c8e72f
Author: Dominik Tobschall <dominik at fruux.com>
Date: Tue Sep 30 14:42:14 2014 +0200
workaround depending on php version
---
lib/TimeZoneUtil.php | 35 ++++++++++++++++++++++++++++++++---
tests/VObject/TimeZoneUtilTest.php | 6 +++---
2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/lib/TimeZoneUtil.php b/lib/TimeZoneUtil.php
index 326e4d5..0d1e98f 100644
--- a/lib/TimeZoneUtil.php
+++ b/lib/TimeZoneUtil.php
@@ -146,15 +146,32 @@ class TimeZoneUtil {
// } catch(\Exception $e) {
// }
$tzIdentifiers = \DateTimeZone::listIdentifiers();
+ $tzIdentifiersWorkaround = self::getIdentifiersWorkaround();
try {
if (
(in_array($tzid, $tzIdentifiers)) ||
(preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) ||
- (in_array($tzid, self::getIdentifiersBC()))
+ (in_array($tzid, self::getIdentifiersBC())) ||
+ (
+ (
+ (version_compare(PHP_VERSION, '5.5.10', '<') || version_compare(PHP_VERSION, '5.5.17', '>=')) ||
+ (defined('HHVM_VERSION'))
+ ) &&
+ (
+ (isset($tzIdentifiersWorkaround[$tzid]))
+ )
+ )
) {
return new \DateTimeZone($tzid);
+ } elseif (
+ (
+ (isset($tzIdentifiersWorkaround[$tzid]))
+ )
+ ) {
+ return new \DateTimeZone($tzIdentifiersWorkaround[$tzid]);
}
+
} catch(\Exception $e) {
}
@@ -244,8 +261,7 @@ class TimeZoneUtil {
self::$map = array_merge(
include __DIR__ . '/timezonedata/windowszones.php',
include __DIR__ . '/timezonedata/lotuszones.php',
- include __DIR__ . '/timezonedata/exchangezones.php',
- include __DIR__ . '/timezonedata/php-workaround.php'
+ include __DIR__ . '/timezonedata/exchangezones.php'
);
}
@@ -265,4 +281,17 @@ class TimeZoneUtil {
return include __DIR__ . '/timezonedata/php-bc.php';
}
+ /**
+ * This method returns an array of timezone identifiers, that are only supported
+ * by PHP 5.5.17 and up as well as HHVM.
+ * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers()
+ *
+ * (See timezonedata/php-workaround.php and timezonedata php-workaround.php)
+ *
+ * @return array
+ */
+ static public function getIdentifiersWorkaround() {
+ return include __DIR__ . '/timezonedata/php-workaround.php';
+ }
+
}
diff --git a/tests/VObject/TimeZoneUtilTest.php b/tests/VObject/TimeZoneUtilTest.php
index 523dbbb..8c1d190 100644
--- a/tests/VObject/TimeZoneUtilTest.php
+++ b/tests/VObject/TimeZoneUtilTest.php
@@ -352,10 +352,10 @@ END:VCALENDAR
HI;
$tz = TimeZoneUtil::getTimeZone('/freeassociation.sourceforge.net/Tzfile/SystemV/EST5EDT', Reader::read($vobj), true);
- if (version_compare(PHP_VERSION, '5.5.10', '>=') && !defined('HHVM_VERSION')) {
- $ex = new \DateTimeZone('America/New_York');
- } else {
+ if (version_compare(PHP_VERSION, '5.5.10', '<') || version_compare(PHP_VERSION, '5.5.17', '>=') || defined('HHVM_VERSION')) {
$ex = new \DateTimeZone('EST5EDT');
+ } else {
+ $ex = new \DateTimeZone('America/New_York');
}
$this->assertEquals($ex->getName(), $tz->getName());
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list