From: <ji...@us...> - 2008-12-15 17:25:33
|
Update of /cvsroot/phpicalendar/phpicalendar/functions/parse In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11278/functions/parse Modified Files: end_vevent.php overlapping_events.php parse_tzs.php Added Files: recur_functions.php Log Message: big changes to recurrence; trying to get closer to the spec --- NEW FILE: recur_functions.php --- <?php /* from the std BYxxx rule parts modify the recurrence in some manner. BYxxx rule parts for a period of time which is the same or greater than the frequency generally reduce or limit the number of occurrences of the recurrence generated. For example, "FREQ=DAILY;BYMONTH=1" reduces the number of recurrence instances from all days (if BYMONTH tag is not present) to all days in January. BYxxx rule parts for a period of time less than the frequency generally increase or expand the number of occurrences of the recurrence. For example, "FREQ=YEARLY;BYMONTH=1,2" increases the number of days within the yearly recurrence set from 1 (if BYMONTH tag is not present) to 2. If multiple BYxxx rule parts are specified, then after evaluating the specified FREQ and INTERVAL rule parts, the BYxxx rule parts are applied to the current set of evaluated occurrences in the following order: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS; then COUNT and UNTIL are evaluated. We will use two kinds of functions - those that restrict the date to allowed values and those that expand allowed values */ function add_recur($times,$freq=''){ global $recur_data; if (!is_array($times)) $times = array($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) if(isset($time)) $recur_data[] = $time; return; } function expand_byday($time){ global $freq_type, $byday, $wkst3char; $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); # echo "$freq_type, ".print_r($byday,true)."$wkst3char $the_sunday"; if (empty($byday)) $byday[] = strtoupper(substr(date('D', $time), 0, 2)); foreach($byday as $key=>$day) { /* set $byday_arr [0] => byday string, e.g. 4TH [1] => sign/modifier [2] => 4 number [3] => TH day abbr */ ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); $on_day = two2threeCharDays($byday_arr[3]); 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); } default: $next_date_time = strtotime($byday_arr[1].$byday_arr[2].$on_day, $time); } $times[] = $next_date_time; } return $times; } function restrict_bymonth($times,$freq=''){ global $bymonth; if (empty($bymonth)) return $times; foreach ($times as $time) if(in_array(date("m", $time), $bymonth)) $new_times[] = $time; return $new_times; } function restrict_byweekno($times,$freq=''){ global $byweekno; if(empty($byweekno)) return $times; foreach ($times as $time) if(in_array(date("W", $time), $byweekno)) $new_times[] = $time; return $new_times; } function restrict_byyearday($times,$freq=''){ global $byyearday; if(empty($byyearday)) return $times; foreach ($times as $time) if(in_array(date("z", $time), $byyearday)) $new_times[] = $time; return $new_times; } function restrict_bymonthday($times,$freq=''){ global $bymonthday; if(empty($bymonthday)) return $times; foreach ($times as $time) if(in_array(date("j", $time), $bymonthday)) $new_times[] = $time; return $new_times; } function restrict_byday($times,$freq=''){ global $byday; if(empty($byday)) return $times; foreach($byday as $key=>$day) $byday3[] = two2threeCharDays($day); foreach ($times as $time) if(in_array(strtolower(date("D", $time)), $byday3)) $new_times[] = $time; return $new_times; } function restrict_bysetpos($times,$freq=''){ global $rrule_array, $bysetpos; if(empty($bysetpos)) return $times; } Index: end_vevent.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/end_vevent.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** end_vevent.php 13 Dec 2008 23:42:31 -0000 1.2 --- end_vevent.php 15 Dec 2008 17:25:28 -0000 1.3 *************** *** 4,13 **** What happens in this file: 1. Initialization: add information not present by default ! 2. */ - if (!isset($url)) $url = ''; - if (!isset($type)) $type = ''; - // Handle DURATION if (!isset($end_unixtime)) { --- 4,15 ---- What happens in this file: 1. Initialization: add information not present by default ! a. duration ! b. class ! c. uid ! d. adjust start_time and end_time ! 2. Build recur_data array ! 3. Add occurrences to master_array */ // Handle DURATION if (!isset($end_unixtime)) { *************** *** 37,47 **** } - if (!isset($summary)) $summary = ''; - if (!isset($description)) $description = ''; - if (!isset($status)) $status = ''; - if (!isset($class)) $class = ''; - if (!isset($location)) $location = ''; - - # adjust event start and end times if (isset($start_time) && isset($end_time)) { --- 39,42 ---- *************** *** 113,136 **** # $rrule_array['END'] = 'end'; } - - $start_date_time = strtotime($start_date); - if (!isset($fromdate)){ - #this should happen if not in one of the rss views - $this_month_start_time = strtotime($this_year.$this_month.'01'); - if ($current_view == 'year' || ($save_parsed_cals == 'yes' && !$is_webcal)|| $current_view == 'print' && $printview == 'year') { - $start_range_time = strtotime($this_year.'-01-01 -2 weeks'); - $end_range_time = strtotime($this_year.'-12-31 +2 weeks'); - } else { - $start_range_time = strtotime('-1 month -2 day', $this_month_start_time); - $end_range_time = strtotime('+2 month +2 day', $this_month_start_time); - } - }else{ - $start_range_time = strtotime($fromdate); - $end_range_time = strtotime($todate)+60*60*24; - } - ! $freq_type = 'year'; ! $interval = 1; # Load $rrule_array foreach ($rrule_array as $key => $val) { --- 108,113 ---- # $rrule_array['END'] = 'end'; } ! $freq_type = 'none'; # Load $rrule_array foreach ($rrule_array as $key => $val) { *************** *** 158,162 **** $abs_until = $until; ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs); ! $until = mktime($regs[4],$regs[5],$regs[6],$regs[2],$regs[3],$regs[1]); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until); break; --- 135,139 ---- $abs_until = $until; ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs); ! $until_unixtime = mktime($regs[4],$regs[5],@$regs[6],$regs[2],$regs[3],$regs[1]); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until); break; *************** *** 168,212 **** break; case 'BYSECOND': ! $bysecond = $val; ! $bysecond = split (',', $bysecond); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond; break; case 'BYMINUTE': ! $byminute = $val; ! $byminute = split (',', $byminute); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute; break; case 'BYHOUR': ! $byhour = $val; ! $byhour = split (',', $byhour); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour; break; case 'BYDAY': ! $byday = $val; ! $byday = split (',', $byday); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday; break; case 'BYMONTHDAY': ! $bymonthday = $val; ! $bymonthday = split (',', $bymonthday); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday; break; case 'BYYEARDAY': ! $byyearday = $val; ! $byyearday = split (',', $byyearday); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday; break; case 'BYWEEKNO': ! $byweekno = $val; ! $byweekno = split (',', $byweekno); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno; break; case 'BYMONTH': ! $bymonth = $val; ! $bymonth = split (',', $bymonth); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth; break; case 'BYSETPOS': ! $bysetpos = $val; $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos; break; --- 145,181 ---- break; case 'BYSECOND': ! $bysecond = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond; break; case 'BYMINUTE': ! $byminute = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute; break; case 'BYHOUR': ! $byhour = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour; break; case 'BYDAY': ! $byday = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday; break; case 'BYMONTHDAY': ! $bymonthday = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday; break; case 'BYYEARDAY': ! $byyearday = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday; break; case 'BYWEEKNO': ! $byweekno = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno; break; case 'BYMONTH': ! $bymonth = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth; break; case 'BYSETPOS': ! $bysetpos = split (',', $val); $recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos; break; *************** *** 217,457 **** } } - /* - Load $recur_array - $recur_array is an array of unix times for instances of an event. This code handles repeats. - Note that dates with exceptions are counted as instances. - RDATE is currently not supported - */ # $recur is the recurrence info that goes into the master array for this VEVENT ! $recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur']; ! ! // if $until isn't set yet, we set it to the end of our range we're looking at ! if (!isset($until)) $until = $end_range_time; ! if (!isset($abs_until)) $abs_until = date('YmdHis', $end_range_time); ! $end_date_time = $until; ! ! // If the $end_range_time is less than the $start_date_time, or $start_range_time is greater ! // than $end_date_time, we may as well forget the whole thing ! // It doesn't do us any good to spend time adding data we aren't even looking at ! // this will prevent the year view from taking way longer than it needs to ! if ($end_range_time >= $start_date_time && $start_range_time_tmp <= $end_date_time) { ! ! // if the beginning of our range is less than the start of the item, we may as well set it equal to it ! if ($start_range_time < $start_date_time){ ! $start_range_time = $start_date_time; ! } ! if ($end_range_time > $end_date_time) $end_range_time = $end_date_time; ! ! // initialize the time we will increment ! $next_range_time = $start_range_time; ! ! // start at the $start_range and go until we hit the end of our range. ! if(!isset($wkst)) $wkst='SU'; ! $wkst3char = two2threeCharDays($wkst); ! # set first instance if it's in range ! $recur_data = array(); ! if ($start_unixtime < $mArray_end && $end_unixtime > $mArray_begin){ ! $recur_data[] = $start_unixtime; ! } ! /* ! The while loop below increments $next_range_time by $freq type. For the larger freq types, there is only ! 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 "<br><br>$summary<br>next range time:".date("Ymd his",$next_range_time)." <br>start range time ".date("Ymd his",$start_range_time)." <br>end range time ".date("Ymd his",$end_range_time); ! while (($next_range_time >= $start_range_time) && ($next_range_time <= $end_range_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',$next_range_time), $start_date); ! $rcount = $diff; ! if(count($byday) > 1) $rcount = $diff * count($byday); ! if ($rcount < $count && $diff % $interval == 0) { ! $year = date('Y', $next_range_time); ! $month = date('m', $next_range_time); ! switch ($rrule_array['FREQ']) { ! case 'DAILY': ! $recur_data[] = $next_range_time; ! break; ! case 'WEEKLY': ! // Populate $byday with the default day if it's not set. ! if (!isset($byday)) $byday[] = strtoupper(substr(date('D', $start_date_time), 0, 2)); ! $the_sunday = dateOfWeek(date("Ymd",$next_range_time), $wkst3char); ! foreach($byday as $key=>$day) { ! $day = two2threeCharDays($day); ! #need to find the first day of the appropriate week. ! if ($key == 0){ ! $next_date_time = strtotime("next $day",strtotime($the_sunday)) + (12 * 60 * 60); ! }else{ ! $next_date_time = strtotime("next $day",$next_date_time) + (12 * 60 * 60); ! } ! $recur_data[] = $next_date_time; #echo "<br>$key $day ".strtotime("Ymd his", $next_date_time); ! } ! break; ! case 'MONTHLY': ! if (empty($bymonth)) $bymonth = array(1,2,3,4,5,6,7,8,9,10,11,12); ! if (!empty($bysetpos)){ ! /* bysetpos code from dustinbutler ! start on day 1 or last day. ! if day matches any BYDAY the count is incremented. ! SETPOS = 4, need 4th match ! SETPOS = -1, need 1st match ! */ ! if ($bysetpos > 0) { ! $next_day = '+1 day'; ! $day = 1; ! } else { ! $next_day = '-1 day'; ! $day = $totalDays[$month]; ! } ! $day = mktime(0, 0, 0, $month, $day, $year); ! $countMatch = 0; ! while ($countMatch != abs($bysetpos)) { ! /* Does this day match a BYDAY value? */ ! $thisDay = $day; ! $textDay = strtoupper(substr(date('D', $thisDay), 0, 2)); ! if (in_array($textDay, $byday)) { ! $countMatch++; ! } ! $day = strtotime($next_day, $thisDay); ! } ! if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time; ! }elseif (count($bymonthday) > 0 && empty($byday)) { ! foreach($bymonthday as $day) { ! if ($day < 0) $day = ((date('t', $next_range_time)) + ($day)) + 1; ! if (checkdate($month,$day,$year)) { ! $next_date_time = mktime(0,0,0,$month,$day,$year); ! if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time; ! } ! } ! } else { ! foreach($byday as $day) { ! /* set $byday_arr ! [0] => byday string, e.g. 4TH ! [1] => sign/modifier ! [2] => 4 number ! [3] => TH day abbr ! */ ! ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); ! $on_day = two2threeCharDays($byday_arr[3]); ! $next_date_time = strtotime($byday_arr[1].$byday_arr[2].$on_day, $next_range_time); ! if(empty($bymonthday) && in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time; ! ! if (isset($bymonthday) && (!empty($bymonthday))) { ! // This supports MONTHLY where BYDAY and BYMONTH are both set ! foreach($bymonthday as $day) { ! if (checkdate($month,$day,$year)) { ! $next_date_time = mktime(0,0,0,$month,$day,$year); ! $daday = strtolower(strftime("%a", $next_date_time)); ! if ($daday == $on_day && in_array($month, $bymonth)) { ! if(in_array(date("m", $next_date_time), $bymonth)) $recur_data[] = $next_date_time; ! } ! } ! } ! } ! } # end foreach $byday ! } ! break; ! case 'YEARLY': ! if ((!isset($bymonth)) || (sizeof($bymonth) == 0)) $bymonth = array(date('m', $start_date_time)); ! foreach($bymonth as $month) { ! if (isset($bysetpos)){ ! /* bysetpos code from dustinbutler ! start on day 1 or last day. ! if day matches any BYDAY the count is incremented. ! SETPOS = 4, need 4th match ! SETPOS = -1, need 1st match ! */ ! if ($bysetpos > 0) { ! $next_day = '+1 day'; ! $day = 1; ! } else { ! $next_day = '-1 day'; ! $day = date("t",$month); ! } ! $day = mktime(12, 0, 0, $month, $day, $year); ! $countMatch = 0; ! while ($countMatch != abs($bysetpos)) { ! /* Does this day match a BYDAY value? */ ! $thisDay = $day; ! $textDay = strtoupper(substr(date('D', $thisDay), 0, 2)); ! if (in_array($textDay, $byday)) { ! $countMatch++; ! } ! $day = strtotime($next_day, $thisDay); ! } ! $recur_data[] = $thisDay; ! } ! if ((isset($byday)) && (is_array($byday))) { ! $checkdate_time = mktime(0,0,0,$month,1,$year); ! foreach($byday as $day) { ! ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); ! if ($byday_arr[2] != '') { ! $nth = $byday_arr[2]-1; ! } else { ! $nth = 0; ! } ! $on_day = two2threeCharDays($byday_arr[3]); ! $on_day_num = two2threeCharDays($byday_arr[3],false); ! if ($byday_arr[1] == '-') { ! $last_day_tmp = date('t',$checkdate_time); ! $checkdate_time = strtotime(date('Y-m-'.$last_day_tmp, $checkdate_time)); ! $last_tmp = (date('w',$checkdate_time) == $on_day_num) ? '' : 'last '; ! $next_date_time = strtotime($last_tmp.$on_day.' -'.$nth.' week', $checkdate_time); ! } else { ! $next_date_time = strtotime($on_day.' +'.$nth.' week', $checkdate_time); ! } ! } ! } else { ! $day = date('d', $start_date_time); ! $next_date_time = mktime(0,0,0,$month,$day,$year+1); ! //echo date('Ymd',$next_date_time).$summary.'<br>'; ! } ! if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time; ! } ! if (isset($byyearday)) { ! foreach ($byyearday as $yearday) { ! ereg ('([-\+]{0,1})?([0-9]{1,3})', $yearday, $byyearday_arr); ! if ($byyearday_arr[1] == '-') { ! $ydtime = mktime(0,0,0,12,31,$this_year); ! $yearnum = $byyearday_arr[2] - 1; ! $next_date_time = strtotime('-'.$yearnum.' days', $ydtime); ! } else { ! $ydtime = mktime(0,0,0,1,1,$this_year); ! $yearnum = $byyearday_arr[2] - 1; ! $next_date_time = strtotime('+'.$yearnum.' days', $ydtime); ! } ! if (isset($next_date_time) && $next_date_time != '') $recur_data[] = $next_date_time; ! } ! } ! break; ! default: ! // anything else we need to end the loop ! $next_range_time = $end_range_time + 100; ! } # end switch ! } ! $next_range_time = strtotime('+'.$interval.' '.$freq_type, $next_range_time); ! } #end while loop ! } # end if time compare ! #foreach($recur_data as $time) echo "<br>".date("Ymd his",$time); # use recur_data array to write the master array // use the same code to write the data instead of always changing it 5 times ! $recur_data_hour = @substr($start_time,0,2); ! $recur_data_minute = @substr($start_time,2,2); ! foreach($recur_data as $recur_data_time) { ! $recur_data_year = date('Y', $recur_data_time); ! $recur_data_month = date('m', $recur_data_time); ! $recur_data_day = date('d', $recur_data_time); $recur_data_date = $recur_data_year.$recur_data_month.$recur_data_day; ! if (($recur_data_time >= $start_date_time) && ($recur_data_time <= $end_date_time) && ($count_to != $count) && !in_array($recur_data_date, $except_dates)) { if (isset($allday_start) && $allday_start != '') { ! $start_time2 = $recur_data_time; ! $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_time); while ($start_time2 < $end_time2) { $start_date2 = date('Ymd', $start_time2); --- 186,281 ---- } } # $recur is the recurrence info that goes into the master array for this VEVENT ! $recur = @$recur_array[($start_date)][($hour.$minute)][$uid]['recur']; ! /* ============================ Load $recur_data ============================ ! $recur_data is an array of unix times for instances of an event. This code handles repeats. ! Note that dates with exceptions are counted as instances. ! RDATE is currently not supported + A. Set up the time range to scan for events. + If COUNT is not set (default is 1,000,000) then we don't have to start at start_date; we can start at the minimum interval for the view. + variables ending in date are in phpical date format: YYYYMMDD + variables ending with time are in phpical time format: HHMM + variables ending in unixtime are in unixtime ! mArray_begin and mArray_end are set in initialization by date_range.php and may be overwritten by rss_common.php. These should be the default for start_range and end_range unixtimes. Conditions where overwrite these: ! COUNT < 1,000,000 - we have to count occurrences; reset next_range_unixtime starting value ! $until_unixtime < $mArray_end - stop iterating early ! !isset($rrule_array['FREQ']) - only iterate once, set the end_range_unixtime to the end_date_unixtime ! Note that start_range_unixtime and end_range_unixtime are not the same as start_date_unixtime and end_date_unixtime */ + $next_range_unixtime = $mArray_begin; + $end_range_unixtime = $mArray_end+60*60*24; + $start_date_unixtime = strtotime($start_date); + if($count < 1000000) $next_range_unixtime = $start_date_unixtime; + if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime; + if(!isset($rrule_array['FREQ'])){ + $end_range_unixtime = strtotime($end_date); + $count = 1; + } + // 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; + + // convert wkst to a 3 char day for strtotime to work + $wkst3char = two2threeCharDays($wkst); + /* The while loop below increments $next_range_time by $freq type. For the larger freq types, there is only + 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)."</pre>"; + $recur_data = array(); + while ($next_range_unixtime <= $end_range_unixtime) { + $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); + switch ($freq_type){ + case 'day': + add_recur($next_range_unixtime); + break; + case 'week': + add_recur(expand_byday($next_range_unixtime)); + break; + case 'month': + $next_date_unixtime = mktime(12,0,0,$month,date('d',$start_unixtime),$year); echo "month".date("Ymd his",$next_date_unixtime); + add_recur(($next_date_unixtime)); + break; + case 'year': + $next_date_unixtime = mktime(12,0,0,date('m',$start_unixtime),date('d',$start_unixtime),$year); echo "year:$hour,$min,0,".date('m',$start_unixtime).",".date('d',$start_unixtime).",$year".date("Ymd his",$next_date_unixtime);print_r($datetime); + add_recur(($next_date_unixtime)); + break; + default: + add_recur($start_unixtime); + break 2; + } + $next_range_unixtime = strtotime('+'.$interval.' '.$freq_type, $next_range_unixtime); + } #end while loop + $recur_data = array_unique($recur_data); + sort($recur_data); + echo "<pre>$summary recur_data:"; + #var_dump($recur_data); + foreach($recur_data as $time) echo "\n".date("Ymd his",$time); + echo "</pre>"; + if ($count < count($recur_data)){ + $arr = array_slice($recur_data,0,$count); + $recur_data =$arr; + } # use recur_data array to write the master array // use the same code to write the data instead of always changing it 5 times ! $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); ! $recur_data_month = date('m', $recur_data_unixtime); ! $recur_data_day = date('d', $recur_data_unixtime); $recur_data_date = $recur_data_year.$recur_data_month.$recur_data_day; ! if ( !in_array($recur_data_date, $except_dates) ) { if (isset($allday_start) && $allday_start != '') { ! $start_time2 = $recur_data_unixtime; ! $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_unixtime); while ($start_time2 < $end_time2) { $start_date2 = date('Ymd', $start_time2); *************** *** 474,478 **** $end_unixtime_tmp = $start_unixtime_tmp + $length; ! if (($end_time >= $bleed_time) && ($bleed_check == '-1')) { $start_tmp = strtotime(date('Ymd',$start_unixtime_tmp)); $end_date_tmp = date('Ymd',$end_unixtime_tmp); --- 298,302 ---- $end_unixtime_tmp = $start_unixtime_tmp + $length; ! if (($end_time >= $phpiCal_config->bleed_time) && ($bleed_check == '-1')) { $start_tmp = strtotime(date('Ymd',$start_unixtime_tmp)); $end_date_tmp = date('Ymd',$end_unixtime_tmp); *************** *** 531,536 **** // Let's double check the until to not write past it - $until_check = $recur_data_date.$hour.$minute.'00'; - if ($abs_until > $until_check) { $master_array[($recur_data_date)][($hour.$minute)][$uid] = array ( 'event_start' => $start_time, --- 355,358 ---- *************** *** 556,560 **** } checkOverlap($recur_data_date, ($hour.$minute), $uid); ! } } } --- 378,382 ---- } checkOverlap($recur_data_date, ($hour.$minute), $uid); ! } } *************** *** 581,584 **** // Clear event data now that it's been saved. unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $description, $status, $class, $location, $organizer, $attendee); ! ?> \ No newline at end of file --- 403,417 ---- // Clear event data now that it's been saved. unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $description, $status, $class, $location, $organizer, $attendee); ! //If you want to see the values in the arrays, uncomment below. ! //print '<pre>'; ! //print_r($master_array); ! //print_r($overlap_array); ! //print_r($day_array); ! //print_r($rrule_array); ! //print_r($byday_arr); ! //print_r($recurrence_delete); ! //print_r($cal_displaynames); ! //print_r($cal_filelist); ! //print_r($tz_array); ! //print '</pre>'; ?> \ No newline at end of file Index: overlapping_events.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/overlapping_events.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** overlapping_events.php 11 Dec 2008 23:48:39 -0000 1.1 --- overlapping_events.php 15 Dec 2008 17:25:28 -0000 1.2 *************** *** 115,119 **** $event = $master_array[$event_date][$event_time][$uid]; // Copy out the array - we replace this at the end. ! $ol_day_array = $overlap_array[$event_date]; $drawTimes = drawEventTimes($event['event_start'], $event['event_end']); --- 115,119 ---- $event = $master_array[$event_date][$event_time][$uid]; // Copy out the array - we replace this at the end. ! $ol_day_array = @$overlap_array[$event_date]; $drawTimes = drawEventTimes($event['event_start'], $event['event_end']); *************** *** 142,146 **** // 'end' - end_time for the overlap block. ! $ol_day_array = $overlap_array[$event_date]; // Track if $event has been merged in, so we don't re-add the details to 'event' or 'overlapRanges' multiple times. $already_merged_once = false; --- 142,146 ---- // 'end' - end_time for the overlap block. ! $ol_day_array = @$overlap_array[$event_date]; // Track if $event has been merged in, so we don't re-add the details to 'event' or 'overlapRanges' multiple times. $already_merged_once = false; Index: parse_tzs.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/parse/parse_tzs.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** parse_tzs.php 13 Dec 2008 23:42:31 -0000 1.2 --- parse_tzs.php 15 Dec 2008 17:25:28 -0000 1.3 *************** *** 18,21 **** --- 18,23 ---- } $line = trim($line); + $is_daylight = false; + $is_std = false; switch ($line) { *************** *** 26,29 **** --- 28,32 ---- unset ($offset_s); $is_std = true; + $is_daylight = false; break; case 'END:STANDARD': *************** *** 34,37 **** --- 37,41 ---- unset ($offset_d); $is_daylight = true; + $is_std = false; break; case 'END:DAYLIGHT': |