|
From: <ji...@us...> - 2008-12-17 09:58:37
|
Update of /cvsroot/phpicalendar/phpicalendar/functions/parse In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14616/functions/parse Modified Files: end_vevent.php recur_functions.php Log Message: progress on recurrence handle some negative values in byxxx rules Index: end_vevent.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/end_vevent.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** end_vevent.php 17 Dec 2008 06:58:53 -0000 1.7 --- end_vevent.php 17 Dec 2008 09:58:30 -0000 1.8 *************** *** 278,283 **** /* ============================ Use $recur_data array to write the master array ============================*/ // This used to use 5 different blocks to write the array... can it be reduced further? ! $recur_data_hour = @substr($start_unixtime,0,2); ! $recur_data_minute = @substr($start_unixtime,2,2); foreach($recur_data as $recur_data_unixtime) { $recur_data_year = date('Y', $recur_data_unixtime); --- 278,283 ---- /* ============================ Use $recur_data array to write the master array ============================*/ // This used to use 5 different blocks to write the array... can it be reduced further? ! $recur_data_hour = @substr($start_time,0,2); ! $recur_data_minute = @substr($start_time,2,2); foreach($recur_data as $recur_data_unixtime) { $recur_data_year = date('Y', $recur_data_unixtime); Index: recur_functions.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/recur_functions.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** recur_functions.php 17 Dec 2008 07:07:57 -0000 1.6 --- recur_functions.php 17 Dec 2008 09:58:30 -0000 1.7 *************** *** 1,3 **** ! <?php /* from the std --- 1,3 ---- ! <?php /* from the std *************** *** 25,29 **** function add_recur($times,$freq=''){ ! global $recur_data, $count, $mArray_begin, $mArray_end, $except_dates, $start_date_unixtime,$end_range_unixtime; if (!is_array($times)) $times = array($times); #echo "add_recur";dump_times($times); --- 25,30 ---- function add_recur($times,$freq=''){ ! global $recur_data; ! global $count, $mArray_begin, $mArray_end, $except_dates, $start_date_unixtime,$end_range_unixtime; if (!is_array($times)) $times = array($times); #echo "add_recur";dump_times($times); *************** *** 35,48 **** $times = restrict_bymonthday($times,$freq); $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",$end_range_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; } --- 36,52 ---- $times = restrict_bymonthday($times,$freq); $times = restrict_byday($times,$freq); ! $times = restrict_bysetpos($times,$freq);#echo "restrict_bysetpos"; ! if($start_date_unixtime > $mArray_begin) $times[] = $start_date_unixtime; $times = array_unique($times); sort($times); $until_date = date("Ymd",$end_range_unixtime); + #dump_times($times); + #dump_times($recur_data); foreach ($times as $time){ ! #echo "time:". date("Ymd",$time)."\n"; $date = date("Ymd",$time); ! $time = strtotime("$date 12:00:00"); ! if(isset($time) && !in_array($time, $recur_data) && !in_array($date, $except_dates) && $time >= $start_date_unixtime && $date <= $until_date){ ! $count--; #echo "."; if($time >= $mArray_begin && $time <= $mArray_end && $count >= 0) $recur_data[] = $time; } *************** *** 95,98 **** --- 99,103 ---- $month = date('m',$time); foreach($bymonthday as $monthday){ + if($monthday < 0) $monthday = date("t",$time) + $monthday +1; $new_times[] = mktime(12,0,0,$month,$monthday,$year); #echo "monthday:$monthday\n"; *************** *** 128,134 **** 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; --- 133,141 ---- if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]); $month_start = strtotime(date("Ym00",$time)); + $month_end = strtotime(date("Ymt",$time))+ (36 * 60 * 60); foreach($week_arr as $week){ ! # echo "<pre>$summary".$byday_arr[1].$week.$on_day,date("Ymd",$month_start)."\n"; ! if($byday_arr[1] == '-') $next_date_time = strtotime($byday_arr[1].$week.$on_day,$month_end); ! else $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; *************** *** 166,170 **** if(empty($byyearday)) return $times; $new_times=array(); ! foreach ($times as $time) if(in_array(date("z", $time), $byyearday)) $new_times[] = $time; return $new_times; } --- 173,186 ---- if(empty($byyearday)) return $times; $new_times=array(); ! foreach ($times as $time){ ! foreach ($byyearday as $yearday){ ! if($yearday < 0){ ! $yearday = 365 + $yearday +1; ! if(date("L",$time)) $yearday += 1; ! } ! $yearday_arr[] = $yearday; ! } ! if(in_array(date("z", $time), $yearday_arr)) $new_times[] = $time; ! } return $new_times; } *************** *** 174,178 **** if(empty($bymonthday)) return $times; $new_times=array(); ! foreach ($times as $time) if(in_array(date("j", $time), $bymonthday)) $new_times[] = $time; return $new_times; } --- 190,200 ---- if(empty($bymonthday)) return $times; $new_times=array(); ! foreach ($times as $time){ ! foreach ($bymonthday as $monthday){ ! if($monthday < 0) $monthday = date("t",$time) + $monthday +1; ! $monthday_arr[] = $monthday; ! } ! if(in_array(date("j", $time), $monthday_arr)) $new_times[] = $time; ! } return $new_times; } |