From: <ji...@us...> - 2008-12-17 06:58:59
|
Update of /cvsroot/phpicalendar/phpicalendar/functions/parse In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv5407/functions/parse Modified Files: end_vevent.php recur_functions.php Log Message: progress on recurrence:until and byday changes Index: end_vevent.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/end_vevent.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** end_vevent.php 16 Dec 2008 19:48:23 -0000 1.6 --- end_vevent.php 17 Dec 2008 06:58:53 -0000 1.7 *************** *** 213,217 **** #conditions where we can not iterate over the whole range ! if($count == 1000000 && $interval == 1) $next_range_unixtime = $mArray_begin; // if the beginning of our range is less than the start of the item, we may as well set it equal to it if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime; --- 213,228 ---- #conditions where we can not iterate over the whole range ! if($count == 1000000){ ! if($interval == 1) { ! $next_range_unixtime = $mArray_begin; ! }else{ ! # can we calculate the right start time? ! # pick the right compare function from date_functions.php ! # $diff is the number of occurrences between start_date and next_range_time ! # $func = $freq_type.'Compare'; ! # $diff = $func(date('Ymd',strtotime($getdate)), $start_date); ! # $next_range_unixtime = strtotime('+'.$diff*$interval.' '.$freq_type, $start_date_unixtime); echo "<pre>$summary\nnext $freq_type $diff $freq_type".date("Ymd",$start_date_unixtime)."\n"; ! } ! } // if the beginning of our range is less than the start of the item, we may as well set it equal to it if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime; *************** *** 219,223 **** if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime; if($freq_type == 'year') $end_range_unixtime += 366*24*60*60; ! if(!isset($rrule_array['FREQ'])){ $end_range_unixtime = strtotime($end_date); $count = 1; --- 230,234 ---- if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime; if($freq_type == 'year') $end_range_unixtime += 366*24*60*60; ! if(!isset($rrule_array['FREQ']) && isset($end_date)){ $end_range_unixtime = strtotime($end_date); $count = 1; *************** *** 229,241 **** one $next_range_time per repeat, but the BYXXX rules may write more than one event in that repeat cycle $next_date_time handles those instances within a $freq_type */ ! #echo "<pre>$summary\n\tstart mArray time:".date("Ymd his",$mArray_begin)."\n\tstart range time:".date("Ymd his",$next_range_unixtime)."\n\tend range time ".date("Ymd his",$end_range_unixtime)."\n"; $recur_data = array(); while ($next_range_unixtime <= $end_range_unixtime && $count > 0) { $year = date('Y', $next_range_unixtime); $month = date('m', $next_range_unixtime); - # pick the right compare function from date_functions.php - # $diff is the number of occurrences between start_date and next_range_time - $func = $freq_type.'Compare'; - $diff = $func(date('Ymd',$next_range_time), $start_date); $time = mktime(12,0,0,$month,date("d",$start_unixtime),$year); switch ($freq_type){ --- 240,248 ---- one $next_range_time per repeat, but the BYXXX rules may write more than one event in that repeat cycle $next_date_time handles those instances within a $freq_type */ ! #echo "<pre>$summary\n\tstart mArray time:".date("Ymd his",$mArray_begin)."\n\tnext_range_unixtime:".date("Ymd his",$next_range_unixtime)."\n\tend range time ".date("Ymd his",$end_range_unixtime)."\n"; $recur_data = array(); while ($next_range_unixtime <= $end_range_unixtime && $count > 0) { $year = date('Y', $next_range_unixtime); $month = date('m', $next_range_unixtime); $time = mktime(12,0,0,$month,date("d",$start_unixtime),$year); switch ($freq_type){ Index: recur_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/recur_functions.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** recur_functions.php 16 Dec 2008 19:48:23 -0000 1.4 --- recur_functions.php 17 Dec 2008 06:58:53 -0000 1.5 *************** *** 25,37 **** function add_recur($times,$freq=''){ ! global $recur_data, $count, $mArray_begin, $mArray_end, $except_dates; if (!is_array($times)) $times = array($times); - $times = array_unique($times); - sort($times); #echo "add_recur";dump_times($times); /*BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS*/ $times = restrict_bymonth($times,$freq); - $times = restrict_byweekno($times,$freq); $times = restrict_byyearday($times,$freq); --- 25,34 ---- function add_recur($times,$freq=''){ ! global $recur_data, $count, $mArray_begin, $mArray_end, $except_dates, $start_date_unixtime,$until_unixtime; if (!is_array($times)) $times = array($times); #echo "add_recur";dump_times($times); /*BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS*/ $times = restrict_bymonth($times,$freq); $times = restrict_byweekno($times,$freq); $times = restrict_byyearday($times,$freq); *************** *** 39,47 **** $times = restrict_byday($times,$freq); $times = restrict_bysetpos($times,$freq);#echo "restrict_bysetpos";dump_times($times); ! foreach ($times as $time){ #echo "time:". date("Ymd",$time); ! if(isset($time) && !in_array(date("Ymd",$time), $except_dates)) $count--; ! if($time >= $mArray_begin && $time <= $mArray_end && $count >= 0) $recur_data[] = $time; } return; --- 36,50 ---- $times = restrict_byday($times,$freq); $times = restrict_bysetpos($times,$freq);#echo "restrict_bysetpos";dump_times($times); ! $times[] = $start_date_unixtime; ! $times = array_unique($times); ! sort($times); ! $until_date = date("Ymd",$until_unixtime); foreach ($times as $time){ #echo "time:". date("Ymd",$time); ! $date = date("Ymd",$time); ! if(isset($time) && !in_array($date, $except_dates) && $time >= $start_date_unixtime && $date <= $until_date){ ! $count--; ! if($time >= $mArray_begin && $time <= $mArray_end && $count >= 0) $recur_data[] = $time; ! } } return; *************** *** 102,107 **** global $freq_type, $byday, $wkst3char, $year, $month, $start_unixtime,$summary; if (empty($byday)) return array($time); $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); ! # echo "$freq_type, ".print_r($byday,true)."$wkst3char $the_sunday"; foreach($byday as $key=>$day) { /* set $byday_arr --- 105,111 ---- global $freq_type, $byday, $wkst3char, $year, $month, $start_unixtime,$summary; if (empty($byday)) return array($time); + $times = array(); $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); ! #echo "<pre>$summary $freq_type ".print_r($byday,true)."$wkst3char $the_sunday</pre>"; foreach($byday as $key=>$day) { /* set $byday_arr *************** *** 115,124 **** switch($freq_type){ case 'week': ! #need to find the first day of the appropriate week. ! if ($key == 0){ ! $next_date_time = strtotime("next $on_day",strtotime($the_sunday)) + (12 * 60 * 60); ! }else{ ! $next_date_time = strtotime("next $on_day",$next_date_time) + (12 * 60 * 60); ! } $times[] = $next_date_time; break; --- 119,124 ---- switch($freq_type){ case 'week': ! #need to find the first day of the appropriate week. ! $next_date_time = strtotime("this $on_day",strtotime($the_sunday)) + (12 * 60 * 60); $times[] = $next_date_time; break; |