From 81e08d85d61dacc8901f906ca530fa80d6648e1d Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 15 Sep 2003 06:28:50 +0000 Subject: Major changes in BYDAY monthly support, added new stuffs to readme and added new calendar to test and fix. --- calendars/Home.ics | 40 +++++++++++++++++++++++ calendars/LACW.ics | 83 +++++++++++++++++++++++++++++++++++++++++++++++ config.inc.php | 2 +- functions/ical_parser.php | 42 ++++++++++++++++-------- month.php | 4 +-- 5 files changed, 154 insertions(+), 17 deletions(-) create mode 100644 calendars/LACW.ics diff --git a/calendars/Home.ics b/calendars/Home.ics index 32667c0..1dc22d6 100644 --- a/calendars/Home.ics +++ b/calendars/Home.ics @@ -127,4 +127,44 @@ UID:99731CF6-92C7-11D7-A4A2-000A95690022 DTSTART;TZID=US/Pacific:20030107T130000 DURATION:PT1H END:VEVENT +BEGIN:VEVENT +SUMMARY:Election Day +DESCRIPTION:Tuesday after 1st Monday in November +DTSTAMP:20030701T000000Z +UID:holiday0013@icaldates.com +CATEGORIES:Holiday - US +DTSTART;VALUE=DATE:17531106 +RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8;BYMONTH=11 +END:VEVENT +BEGIN:VEVENT +EXDATE;TZID=US/Eastern:20030407T095000 +EXDATE;TZID=US/Eastern:20020107T095000 +EXDATE;TZID=US/Eastern:20020204T095000 +EXDATE;TZID=US/Eastern:20020304T095000 +EXDATE;TZID=US/Eastern:20020401T095000 +EXDATE;TZID=US/Eastern:20020506T095000 +EXDATE;TZID=US/Eastern:20020603T095000 +EXDATE;TZID=US/Eastern:20020701T095000 +EXDATE;TZID=US/Eastern:20020805T095000 +EXDATE;TZID=US/Eastern:20020902T095000 +EXDATE;TZID=US/Eastern:20021007T095000 +EXDATE;TZID=US/Eastern:20021104T095000 +EXDATE;TZID=US/Eastern:20021202T095000 +EXDATE;TZID=US/Eastern:20030106T095000 +EXDATE;TZID=US/Eastern:20030203T095000 +EXDATE;TZID=US/Eastern:20030303T095000 +EXDATE;TZID=US/Eastern:20030505T095000 +EXDATE;TZID=US/Eastern:20030602T095000 +EXDATE;TZID=US/Eastern:20030804T095000 +EXDATE;TZID=US/Eastern:20030901T095000 +EXDATE;TZID=US/Eastern:20030707T095000 +UID:D9040425-RID +SUMMARY:Water Aloe Plant +DTSTART;TZID=US/Eastern:20020107T095000 +DTSTAMP:20030819T222017Z +DURATION:PT10M +RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=1MO +END:VEVENT + + END:VCALENDAR diff --git a/calendars/LACW.ics b/calendars/LACW.ics new file mode 100644 index 0000000..67a7220 --- /dev/null +++ b/calendars/LACW.ics @@ -0,0 +1,83 @@ +BEGIN:VCALENDAR +CALSCALE:GREGORIAN +X-WR-TIMEZONE;VALUE=TEXT:US/Mountain +PRODID:-//Apple Computer\, Inc//iCal 1.0//EN +X-WR-RELCALID;VALUE=TEXT:4C3F5D0E-D051-11D7-A119-00306583A102-CALP +X-WR-CALNAME;VALUE=TEXT:LACW +VERSION:2.0 +BEGIN:VEVENT +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +DTSTAMP:20030817T012730Z +SUMMARY:Los Alamos Community winds at the White Rock Baptist Church + (Vives & Beethoven's 5th\, 2nd movement) +DTSTART;TZID=US/Mountain:20030812T190000 +DTEND;TZID=US/Mountain:20030812T210000 +RRULE:FREQ=WEEKLY;UNTIL=20031005T055959;INTERVAL=1;BYDAY=TU +END:VEVENT +BEGIN:VEVENT +RECURRENCE-ID;TZID=US/Mountain:20030826T190000 +DTSTAMP:20030817T012938Z +SUMMARY:Cancelled: Los Alamos Community winds at the White Rock Baptist + Church +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +DTSTART;TZID=US/Mountain:20030826T190000 +DURATION:PT2H +END:VEVENT +BEGIN:VEVENT +SUMMARY:Los Alamos Community winds at the White Rock Baptist Church + (Copland & Beethoven's 5th\, 3rd & 4th movements) +DURATION:PT2H +RECURRENCE-ID;TZID=US/Mountain:20030819T190000 +DTSTART;TZID=US/Mountain:20030819T190000 +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +END:VEVENT +BEGIN:VEVENT +SUMMARY:Los Alamos Community winds at the Los Alamos Middle School + (Grainger & Beethoven's 5th\, 1st & 2nd movements) +DURATION:PT2H +RECURRENCE-ID;TZID=US/Mountain:20030902T190000 +DTSTART;TZID=US/Mountain:20030902T190000 +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +END:VEVENT +BEGIN:VEVENT +RECURRENCE-ID;TZID=US/Mountain:20030909T190000 +DTSTAMP:20030817T013316Z +SUMMARY:Los Alamos Community winds at the Los Alamos Middle School + (Susato\, Vives\, & Beethoven's 5th\, 3rd & 4th movements) +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +DTSTART;TZID=US/Mountain:20030909T190000 +DURATION:PT2H +END:VEVENT +BEGIN:VEVENT +RECURRENCE-ID;TZID=US/Mountain:20030916T190000 +DTSTAMP:20030817T013302Z +SUMMARY:Los Alamos Community winds at the Los Alamos Middle School + (Mendelssohn & Beethoven's 5th) +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +DTSTART;TZID=US/Mountain:20030916T190000 +DURATION:PT2H +END:VEVENT +BEGIN:VEVENT +SUMMARY:Los Alamos Community winds at the Los Alamos Middle School + (Copland\, Grainger\, & Beethoven's 5th) +DURATION:PT2H +RECURRENCE-ID;TZID=US/Mountain:20030923T190000 +DTSTART;TZID=US/Mountain:20030923T190000 +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +END:VEVENT +BEGIN:VEVENT +SUMMARY:Los Alamos Community winds at the Los Alamos Middle School (Dress + Rehearsal) +DURATION:PT2H +RECURRENCE-ID;TZID=US/Mountain:20030930T190000 +DTSTART;TZID=US/Mountain:20030930T190000 +UID:5ECEAD4E-D051-11D7-A119-00306583A102-RID +END:VEVENT +BEGIN:VEVENT +UID:1F3E3CC2-D053-11D7-A119-00306583A102-RID +DTSTAMP:20030817T013656Z +SUMMARY:LACW Concert at the Betty Ehart Senior Center +DTSTART;TZID=US/Mountain:20031004T193000 +DTEND;TZID=US/Mountain:20031004T213000 +END:VEVENT +END:VCALENDAR diff --git a/config.inc.php b/config.inc.php index 95f30f7..a3e9409 100644 --- a/config.inc.php +++ b/config.inc.php @@ -30,7 +30,7 @@ $cookie_uri = ''; // The HTTP URL to the PHP iCalendar directory, ie. htt $download_uri = ''; // The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars // Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase. -$save_parsed_cals = 'yes'; // Recommended 'yes'. Saves a copy of the cal in /tmp after it's been parsed. Improves performence. +$save_parsed_cals = 'no'; // Recommended 'yes'. Saves a copy of the cal in /tmp after it's been parsed. Improves performence. $use_sessions = 'no'; // This has not yet been implemented. $display_custom_goto = 'no'; // In the 'Jump To' box, display the custom 'go to day' box. $display_ical_list = 'yes'; // In the 'Jump To' box, display the pop-up menu with the list of all calendars in the $calendar_path directory. diff --git a/functions/ical_parser.php b/functions/ical_parser.php index a823674..9fc0631 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -97,7 +97,7 @@ foreach ($cal_filelist as $filename) { $allday_start, $allday_end, $start, $end, $the_duration, $beginning, $rrule_array, $start_of_vevent, $description, $valarm_description, $start_unixtime, $end_unixtime, - $recurrence_id, $uid, $class, $location + $recurrence_id, $uid, $class, $location, $rrule ); $except_dates = array(); @@ -431,7 +431,7 @@ foreach ($cal_filelist as $filename) { case 'MONTHLY': $next_range_time = strtotime(date('Y-m-01', $next_range_time)); // month has two cases, either $bymonthday or $byday - if (is_array($bymonthday)) { + if ((is_array($bymonthday)) && (!is_array($byday))) { // loop through the days on which this event happens foreach($bymonthday as $day) { $year = date('Y', $next_range_time); @@ -445,20 +445,35 @@ foreach ($cal_filelist as $filename) { } else { // loop through the days on which this event happens foreach($byday as $day) { - ereg ('([-\+]{0,1})([0-9]{1})([A-Z]{2})', $day, $byday_arr); + ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); $nth = $byday_arr[2]-1; $on_day = two2threeCharDays($byday_arr[3]); $on_day_num = two2threeCharDays($byday_arr[3],false); - if ($byday_arr[1] == '-') { + if ((isset($byday_arr[1])) && ($byday_arr[1] == '-')) { $last_day_tmp = date('t',$next_range_time); $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); - } else { + } 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); + 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)) { + $recur_data[] = $next_date_time; + } + } + } + } elseif (isset($byday_arr[1])) { $next_date_time = strtotime($on_day.' +'.$nth.' week', $next_range_time); + $recur_data[] = $next_date_time; } $next_date = date('Ymd', $next_date_time); - $recur_data[] = $next_date_time; + //$recur_data[] = $next_date_time; } } break; @@ -469,7 +484,7 @@ foreach ($cal_filelist as $filename) { 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); + ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); $nth = $byday_arr[2]-1; $on_day = two2threeCharDays($byday_arr[3]); if ($byday_arr[1] == '-') { @@ -954,15 +969,14 @@ if ($parse_file) { //If you want to see the values in the arrays, uncomment below. -/* -print '
';
-print_r($master_array);
-print_r($overlap_array);
+
+//print '
';
+//print_r($master_array);
+//print_r($overlap_array);
 //print_r($day_array);
-//print_r($rrule);
+//print_r($rrule_array);
 //print_r($recurrence_delete);	
-print '
'; -*/ +//print '
'; // Set a calender name for all calenders combined if ($cal == 'all_calenders_combined971') { diff --git a/month.php b/month.php index 8af0d59..55e7a83 100644 --- a/month.php +++ b/month.php @@ -126,8 +126,8 @@ $num_of_events = 0; } } if ($i == 0) echo ''; - echo ''; if (isset($master_array[("$daylink")])) { + echo ''; echo '
'.$day.'
'; echo '
'; if ($master_array[("$daylink")]) { @@ -162,7 +162,7 @@ $num_of_events = 0; echo ''; } else { echo ''; - echo ''.$day.''; + echo '
'.$day.'
'; echo ''; } $sunday = strtotime("+1 day", $sunday); -- cgit v1.2.3