From e15c3d3b5849d8af9779b26d64cb4fb776a623f3 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 15 Apr 2010 20:25:32 +1200 Subject: [PATCH] Use the new olson_from_tzstring() function to extract the Olson tz. --- inc/RRule-v2.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/inc/RRule-v2.php b/inc/RRule-v2.php index f20104d3..f204e7f8 100644 --- a/inc/RRule-v2.php +++ b/inc/RRule-v2.php @@ -49,15 +49,19 @@ class RepeatRuleTimeZone extends DateTimeZone { } catch (Exception $e) { $original = $dtz; - if ( preg_match( '{((([^/]+)/)?[^/]+)$}', $dtz, $matches ) ) { - $dtz = $matches[1]; - dbg_error_log( 'RRule', 'Found timezone "%s", will process as "%s"', $original, $dtz ); + $dtz = olson_from_tzstring($dtz); + if ( isset($dtz) ) { + try { + parent::__construct($dtz); + $this->tzid = $dtz; + } + catch (Exception $e) { + dbg_error_log( 'ERROR', 'Could not parse timezone "%s" - will use floating time', $original ); + $dtz = new DateTimeZone('UTC'); + $this->tzid = false; + } } - try { - parent::__construct($dtz); - $this->tzid = $dtz; - } - catch (Exception $e) { + else { dbg_error_log( 'ERROR', 'Could not parse timezone "%s" - will use floating time', $original ); $dtz = new DateTimeZone('UTC'); $this->tzid = false;