From c452f07e732f6a4885f0c8c28a65a7c03b298283 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 2 Sep 2010 23:03:57 +1200 Subject: [PATCH] Try harder to get the right duration for an event. --- inc/RRule-v2.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/inc/RRule-v2.php b/inc/RRule-v2.php index abf9a0ae..65983913 100644 --- a/inc/RRule-v2.php +++ b/inc/RRule-v2.php @@ -101,11 +101,7 @@ class RepeatRuleDateTime extends DateTime { $this->tzid = null; } } - elseif ( is_string($dtz) ) { - $dtz = new RepeatRuleTimeZone($dtz); - $this->tzid = $dtz->tzid(); - } - elseif( $dtz === null ) { + elseif( $dtz === null || $dtz == '' ) { $dtz = new RepeatRuleTimeZone('UTC'); if ( preg_match('/(\d{8}(T\d{6})?)Z/', $date, $matches) ) { if ( strlen($matches[1]) == 8 ) $this->is_date = true; @@ -115,6 +111,10 @@ class RepeatRuleDateTime extends DateTime { $this->tzid = null; } } + elseif ( is_string($dtz) ) { + $dtz = new RepeatRuleTimeZone($dtz); + $this->tzid = $dtz->tzid(); + } else { $this->tzid = $dtz->getName(); } @@ -145,6 +145,9 @@ class RepeatRuleDateTime extends DateTime { if ( isset($matches[8]) && $matches[8] != '' ) $interval .= $minus . $matches[9] . ' minutes '; if (isset($matches[10]) &&$matches[10] != '' ) $interval .= $minus . $matches[11] . ' seconds '; } +// printf( "Modify '%s' by: >>%s<<\n", $this->__toString(), $interval ); +// print_r($this); + if ( !isset($interval) || $interval == '' ) $interval = '1 day'; parent::modify($interval); return $this->__toString(); } @@ -789,7 +792,7 @@ function expand_event_instances( $vResource, $range_start = null, $range_end = n $end_type = ($comp->GetType() == 'VTODO' ? 'DUE' : 'DTEND'); $duration = $comp->GetProperty('DURATION'); - if ( !isset($duration) ) { + if ( !isset($duration) || $duration->Value() == '' ) { $instance_start = $comp->GetProperty('DTSTART'); $dtsrt = new RepeatRuleDateTime( $instance_start->Value(), $instance_start->GetParameterValue('TZID')); $instance_end = $comp->GetProperty($end_type);