From 6c80bc51a1f1d1aafe7566ff8b275592076f13c8 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 21 Sep 2003 18:18:19 +0000 Subject: Somewhat better BYMONTH support. Still seems flakey in year view for some reason. :( --- functions/ical_parser.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'functions') diff --git a/functions/ical_parser.php b/functions/ical_parser.php index ef49844..40e377d 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -438,6 +438,7 @@ foreach ($cal_filelist as $filename) { } break; case 'MONTHLY': + if (!isset($bymonth)) $bymonth = array(1,2,3,4,5,6,7,8,9,10,11,12); $next_range_time = strtotime(date('Y-m-01', $next_range_time)); // month has two cases, either $bymonthday or $byday if ((is_array($bymonthday)) && (!is_array($byday))) { @@ -463,9 +464,12 @@ foreach ($cal_filelist as $filename) { $next_range_time = strtotime(date('Y-m-'.$last_day_tmp, $next_range_time)); $last_tmp = (date('w',$next_range_time) == $on_day_num) ? '' : 'last '; $next_date_time = strtotime($last_tmp.$on_day.' -'.$nth.' week', $next_range_time); + $month = date('m', $next_date_time); + if (in_array($month, $bymonth)) { + $recur_data[] = $next_date_time; + } } elseif (is_array($bymonthday)) { // This supports MONTHLY where BYDAY and BYMONTH are both set - if (!isset($bymonth)) $bymonth = array(1,2,3,4,5,6,7,8,9,10,11,12); foreach($bymonthday as $day) { $year = date('Y', $next_range_time); $month = date('m', $next_range_time); @@ -477,9 +481,12 @@ foreach ($cal_filelist as $filename) { } } } - } elseif (isset($byday_arr[1])) { + } elseif ((isset($byday_arr[1])) && ($byday_arr[1] != '-')) { $next_date_time = strtotime($on_day.' +'.$nth.' week', $next_range_time); - $recur_data[] = $next_date_time; + $month = date('m', $next_date_time); + if (in_array($month, $bymonth)) { + $recur_data[] = $next_date_time; + } } $next_date = date('Ymd', $next_date_time); //$recur_data[] = $next_date_time; -- cgit v1.2.3