gunnar: server/php-kolab/Kolab_Freebusy/Freebusy recurrence.class.php, 1.1, 1.2
cvs at kolab.org
cvs at kolab.org
Thu Aug 16 12:24:05 CEST 2007
Author: gunnar
Update of /kolabrepository/server/php-kolab/Kolab_Freebusy/Freebusy
In directory doto:/tmp/cvs-serv1666/Freebusy
Modified Files:
recurrence.class.php
Log Message:
fixed kolab/issue1637 (Recurrency issues)
Index: recurrence.class.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Freebusy/Freebusy/recurrence.class.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- recurrence.class.php 7 Aug 2007 15:45:56 -0000 1.1
+++ recurrence.class.php 16 Aug 2007 10:24:03 -0000 1.2
@@ -62,6 +62,7 @@
myLog( 'Recurrence::expand( '.Recurrence::ts2string($startstamp).", "
.Recurrence::ts2string($endstamp).' ), cycletype='.$this->cycle_type,
RM_LOG_DEBUG);
+ if ( $this->range_type == 'date' && $this->range < 0) { myLog("range is =".$this->range,RM_LOG_DEBUG);$this->range=2147397240;myLog("reset range to =".$this->range,RM_LOG_DEBUG);}
switch( $this->cycle_type ) {
case 'daily':
$this->expand_daily( $startstamp, $endstamp );
@@ -90,7 +91,7 @@
function expand_daily( $startstamp, $endstamp ) {
// Daily recurrence, every 'interval' days
$duration = $this->initial_end-$this->initial_start;
- $count = 0;
+ $count = 1;
if( !$this->interval ) $this->interval = 1;
for( $t = $this->initial_start; $t < $endstamp; $t = strtotime( '+'.$this->interval.' days',$t) ) {
//myLog("Adding recurrence $t -> ".($t+$duration), RM_LOG_DEBUG );
@@ -108,14 +109,22 @@
// Weekly recurrence, every 'interval' weeks on 'day' days
$duration = $this->initial_end-$this->initial_start;
if( !$this->interval ) $this->interval = 1;
- $count = 0;
+ $count = 1;
+ myLog(" starting with freebusy interval $startstamp till $endstamp and rec period ".$this->initial_start. " till ".$this->initial_end,RM_LOG_DEBUG);
+ myLog(" starting with freebusy interval ".gmdate("D, M d Y H:i:s",$startstamp)." till ".gmdate("D, M d Y H:i:s",$endstamp)." and rec period ".gmdate("D, M d Y H:i:s",$this->initial_start). " till ".gmdate("D, M d Y H:i:s",$this->initial_end),RM_LOG_DEBUG);
+ $realstartdate='';
+ if ($this->initial_start < $startstamp) { $realstartdate=$startstamp;} else {$realstartdat=$this->initial_start;}
$delta_days = (int)gmdate('w',$this->initial_start);
+ myLog ("delta=".$delta_days." loop from ".strtotime("-$delta_days days", $this->initial_start)." till ".$endstamp. "with steps ".strtotime( '+'.$this->interval.' weeks', $t),RM_LOG_DEBUG);
+ myLog ("delta=".$delta_days." loop from ".gmdate("D, M d Y H:i:s",$this->initial_start)." till ".gmdate("D, M d Y H:i:s",$endstamp). "with steps ".$this->interval." weeks",RM_LOG_DEBUG);
for( $t = strtotime("-$delta_days days", $this->initial_start); $t < $endstamp;
$t = strtotime( '+'.$this->interval.' weeks', $t) ) {
- //myLog("t=".gmdate("D, M d Y H:i:s",$t), RM_LOG_DEBUG);
+ myLog("t=".gmdate("D, M d Y H:i:s",$t), RM_LOG_DEBUG);
foreach( $this->day as $day ) {
+ myLog("day is t=".$day, RM_LOG_DEBUG);
$tmp = strtotime( '+'.$this->dayname2number($day).' days', $t);
- if( $tmp >= $this->initial_start && $tmp < $endstamp &&
+ myLog("tmp is t=".$tmp. ' or '.gmdate("D, M d Y H:i:s",$tmp), RM_LOG_DEBUG);
+ if( $tmp >= $realstartdate && $tmp < $endstamp &&
!$this->isExcluded( $tmp, $tmp+$duration) ) {
myLog("Adding recurrence ".gmdate("D, M d Y H:i:s",$tmp)." -> "
.gmdate("D, M d Y H:i:s",$tmp+$duration), RM_LOG_DEBUG );
@@ -125,6 +134,7 @@
}
}
$count++;
+myLog("range is =".$this->range." t is ".$t,RM_LOG_DEBUG);
if( $this->range_type == 'number' && $count > $this->range ) {
break;
} else if( $this->range_type == 'date' && $t > strtotime( '+1 day',$this->range ) ) {
@@ -137,7 +147,7 @@
// Weekly recurrence, every 'interval' weeks
$duration = $this->initial_end-$this->initial_start;
if( !$this->interval ) $this->interval = 1;
- $count = 0;
+ $count = 1;
$delta_days = (int)gmdate('d',$this->initial_start);
myLog("initial_start=".Recurrence::ts2string($this->initial_start), RM_LOG_DEBUG);
$offset = 0;
@@ -198,7 +208,7 @@
function expand_yearly( $startstamp, $endstamp ) {
$duration = $this->initial_end-$this->initial_start;
if( !$this->interval ) $this->interval = 1;
- $count = 0;
+ $count = 1;
$delta_days = (int)gmdate('z',$this->initial_start);
for( $t = strtotime( "-$delta_days days", $this->initial_start ); $t < $endstamp;
$t = strtotime( '+'.$this->interval.' years', $t) ) {
More information about the commits
mailing list