From: <ji...@us...> - 2008-12-16 19:48:28
|
Update of /cvsroot/phpicalendar/phpicalendar/functions/parse In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv28037/functions/parse Modified Files: end_vevent.php recur_functions.php Log Message: progress on recurrence Index: end_vevent.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/end_vevent.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** end_vevent.php 16 Dec 2008 15:46:24 -0000 1.5 --- end_vevent.php 16 Dec 2008 19:48:23 -0000 1.6 *************** *** 229,233 **** 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) { --- 229,233 ---- 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) { *************** *** 238,241 **** --- 238,242 ---- $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){ case 'day': *************** *** 246,250 **** break; case 'month': - $time = mktime(12,0,0,$month,date("d",$start_unixtime),$year); $times = expand_bymonthday(array($time)); foreach($times as $time){ --- 247,250 ---- *************** *** 253,260 **** break; case 'year': ! $times = expand_bymonth($next_range_unixtime); ! $times = expand_byweekno($times); ! $times = expand_byyearday($times); ! $times = expand_bymonthday($times); foreach($times as $time){ add_recur(expand_byday($time)); --- 253,260 ---- break; case 'year': ! $times = expand_bymonth($time); #echo "exp bymonth";dump_times($times); ! $times = expand_byweekno($times); #echo "exp bymonth";dump_times($times); ! $times = expand_byyearday($times); #echo "exp bymonth";dump_times($times); ! $times = expand_bymonthday($times); #echo "exp bymonthday";dump_times($times); foreach($times as $time){ add_recur(expand_byday($time)); *************** *** 265,269 **** break 2; } ! $next_range_unixtime = strtotime('+'.$interval.' '.$freq_type, $next_range_unixtime); echo "\nnext $interval $freq_type".date("Ymd",$next_range_unixtime)."\n"; } #end while loop sort($recur_data); --- 265,269 ---- break 2; } ! $next_range_unixtime = strtotime('+'.$interval.' '.$freq_type, $next_range_unixtime); #echo "\nnext $interval $freq_type".date("Ymd",$next_range_unixtime)."\n"; } #end while loop sort($recur_data); Index: recur_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/recur_functions.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** recur_functions.php 16 Dec 2008 15:46:24 -0000 1.3 --- recur_functions.php 16 Dec 2008 19:48:23 -0000 1.4 *************** *** 29,43 **** $times = array_unique($times); sort($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); $times = restrict_bymonthday($times,$freq); $times = restrict_byday($times,$freq); ! $times = restrict_bysetpos($times,$freq); 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; --- 29,45 ---- $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); $times = restrict_bymonthday($times,$freq); $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; *************** *** 85,96 **** function expand_bymonthday($times){ ! global $bymonthday, $year, $month; if (empty($bymonthday)) return $times; ! foreach($times as $time) foreach($bymonthday as $monthday) $new_times[] = mktime(12,0,0,$month,$monthday,$year); return $new_times; } function expand_byday($time){ ! global $freq_type, $byday, $wkst3char, $year, $month, $start_unixtime; if (empty($byday)) return array($time); $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); --- 87,104 ---- function expand_bymonthday($times){ ! global $bymonthday, $year; if (empty($bymonthday)) return $times; ! foreach($times as $time){ ! $month = date('m',$time); ! foreach($bymonthday as $monthday){ ! $new_times[] = mktime(12,0,0,$month,$monthday,$year); ! #echo "monthday:$monthday\n"; ! } ! } return $new_times; } function expand_byday($time){ ! global $freq_type, $byday, $wkst3char, $year, $month, $start_unixtime,$summary; if (empty($byday)) return array($time); $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); *************** *** 118,127 **** case 'year': $week_arr = array(1,2,3,4,5); ! if(isset($byday_arr[2])) $week_arr = array($byday_arr[2]); ! $month_start = strtotime(date("Ym01",$time)); foreach($week_arr as $week){ $next_date_time = strtotime($byday_arr[1].$week.$on_day,$month_start); # check that we're still in the same month ! if (date("m",$next_date_time) == date("m",$month_start) ) $times[] = $next_date_time; } break; --- 126,136 ---- case 'year': $week_arr = array(1,2,3,4,5); ! if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]); ! $month_start = strtotime(date("Ym00",$time)); foreach($week_arr as $week){ + #echo "<pre>$summary".$byday_arr[1].$week.$on_day,date("Ymd",$month_start)."\n"; $next_date_time = strtotime($byday_arr[1].$week.$on_day,$month_start); # check that we're still in the same month ! if (date("m",$next_date_time) == date("m",$time) ) $times[] = $next_date_time; } break; *************** *** 131,135 **** } } ! dump_times($times); return $times; } --- 140,144 ---- } } ! #echo "exp byday";dump_times($times); return $times; } *************** *** 197,205 **** } ! function dump_times($recur_data){ global $summary; ! echo "<pre>$summary recur_data:"; ! var_dump($recur_data); ! foreach($recur_data as $time) echo "\n".date("Ymd his",$time); echo "</pre>"; } --- 206,215 ---- } ! # for diagnostics ! function dump_times($times){ global $summary; ! echo "<pre>$summary times:"; ! var_dump($times); ! foreach($times as $time) echo "\ndate:".date("Ymd his",$time); echo "</pre>"; } |