Update of /cvsroot/phpicalendar/phpicalendar/functions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23031/functions
Modified Files:
ical_parser.php
Log Message:
recur bug fix...add bysetpos support
Index: ical_parser.php
===================================================================
RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v
retrieving revision 1.208
retrieving revision 1.209
diff -C2 -d -r1.208 -r1.209
*** ical_parser.php 21 Mar 2006 09:52:29 -0000 1.208
--- ical_parser.php 9 Apr 2006 00:32:48 -0000 1.209
***************
*** 460,465 ****
--- 460,467 ----
break;
case 'INTERVAL':
+ if ($val > 0){
$number = $val;
$master_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $number;
+ }
break;
case 'BYSECOND':
***************
*** 565,569 ****
// Populate $byday with the default day if it's not set.
if (!isset($byday)) {
! $byday[] = strtoupper(substr($daysofweekshort_lang[date('w', $start_date_time)], 0, 2));
}
if (is_array($byday)) {
--- 567,571 ----
// Populate $byday with the default day if it's not set.
if (!isset($byday)) {
! $byday[] = strtoupper(substr(date('D', $start_date_time), 0, 2));
}
if (is_array($byday)) {
***************
*** 592,596 ****
$next_range_time = strtotime(date('Y-m-01', $next_range_time));
$next_date_time = $next_date_time;
! if ((isset($bymonthday)) && (!isset($byday))) {
foreach($bymonthday as $day) {
if ($day < 0) $day = ((date('t', $next_range_time)) + ($day)) + 1;
--- 594,626 ----
$next_range_time = strtotime(date('Y-m-01', $next_range_time));
$next_date_time = $next_date_time;
! 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
! */
! $year = date('Y', $next_range_time);
! $month = date('m', $next_range_time);
! 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);
! }
! $recur_data[] = $thisDay;
! }elseif ((isset($bymonthday)) && (!isset($byday))) {
foreach($bymonthday as $day) {
if ($day < 0) $day = ((date('t', $next_range_time)) + ($day)) + 1;
***************
*** 662,666 ****
$year = date('Y', $next_range_time);
}
!
if ((isset($byday)) && (is_array($byday))) {
$checkdate_time = mktime(0,0,0,$month,1,$year);
--- 692,722 ----
$year = date('Y', $next_range_time);
}
! 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);
|