diff options
author | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-18 09:22:23 +0000 |
---|---|---|
committer | Jim Hu <jimhu@users.sourceforge.net> | 2008-12-18 09:22:23 +0000 |
commit | fc4ef652b9565c913a805c3f4010cd1c95476196 (patch) | |
tree | 823dc7bb4222c980e3f3d7573c2639f4f6d06b88 | |
parent | c11f05eba87d73124d3afa2dfa607d0ca0857bd4 (diff) | |
download | phpicalendar-fc4ef652b9565c913a805c3f4010cd1c95476196.tar.gz phpicalendar-fc4ef652b9565c913a805c3f4010cd1c95476196.tar.bz2 phpicalendar-fc4ef652b9565c913a805c3f4010cd1c95476196.zip |
recurrence changes, add recur_tests calendars subdirectory, fix cpath
-rw-r--r-- | calendars/recur_tests/ex_set1.ics | 73 | ||||
-rw-r--r-- | calendars/recur_tests/ex_set2.ics | 81 | ||||
-rw-r--r-- | calendars/recur_tests/ex_set3.ics | 82 | ||||
-rw-r--r-- | calendars/recur_tests/ex_set4.ics | 83 | ||||
-rw-r--r-- | calendars/recur_tests/ex_set5.ics | 81 | ||||
-rw-r--r-- | calendars/recur_tests/ex_set6.ics | 62 | ||||
-rw-r--r-- | functions/ical_parser.php | 2 | ||||
-rw-r--r-- | functions/init/cpaths.php | 1 | ||||
-rw-r--r-- | functions/parse/end_vevent.php | 11 | ||||
-rw-r--r-- | functions/parse/recur_functions.php | 110 | ||||
-rw-r--r-- | functions/template.php | 2 |
11 files changed, 537 insertions, 51 deletions
diff --git a/calendars/recur_tests/ex_set1.ics b/calendars/recur_tests/ex_set1.ics new file mode 100644 index 0000000..c4c64be --- /dev/null +++ b/calendars/recur_tests/ex_set1.ics @@ -0,0 +1,73 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 1 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Daily for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=DAILY;COUNT=10 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Daily until December 24, 1997 +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=DAILY;UNTIL=19971224T000000Z +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other day - forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=DAILY;INTERVAL=2 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every 10 days, 5 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every day in Jan 3 years +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19980101T090000 +RRULE:FREQ=YEARLY;UNTIL=20000131T090000Z; + BYMONTH=1;BYDAY=SU,MO,TU,WE,TH,FR,SA +END:VEVENT +END:VCALENDAR diff --git a/calendars/recur_tests/ex_set2.ics b/calendars/recur_tests/ex_set2.ics new file mode 100644 index 0000000..d57e5d8 --- /dev/null +++ b/calendars/recur_tests/ex_set2.ics @@ -0,0 +1,81 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 2 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every day in Jan 3 years (alt) +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19980101T090000 +RRULE:FREQ=DAILY;UNTIL=20000131T090000Z;BYMONTH=1 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Weekly for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;COUNT=10 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Weekly until December 24, 1997 +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;UNTIL=19971224T000000Z +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other week - forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;INTERVAL=2;WKST=SU +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Weekly on Tuesday and Thursday for 5 weeks - goes 1 extra? +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Weekly on Tuesday and Thursday for 5 weeks (alt) +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH +END:VEVENT +END:VCALENDAR diff --git a/calendars/recur_tests/ex_set3.ics b/calendars/recur_tests/ex_set3.ics new file mode 100644 index 0000000..c657b6e --- /dev/null +++ b/calendars/recur_tests/ex_set3.ics @@ -0,0 +1,82 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 3 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other week on Monday, Wednesday and Friday until December 24, 1997, but starting on Tuesday, September 2, 1997 +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other week on Tuesday and Thursday, for 8 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Pacific:19970902T090000 +RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monthly on the 1st Friday for ten occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970905T090000 +RRULE:FREQ=MONTHLY;COUNT=10;BYDAY=1FR +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monthly on the 1st Friday until December 24, 1997 +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970905T090000 +RRULE:FREQ=MONTHLY;UNTIL=19971224T000000Z;BYDAY=1FR +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other month on the 1st and last Sunday of the month for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970907T090000 +RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU +END:VEVENT +END:VCALENDAR +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monthly on the second to last Monday of the month for 6 months +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970922T090000 +RRULE:FREQ=MONTHLY;COUNT=6;BYDAY=-2MO +END:VEVENT +END:VCALENDAR diff --git a/calendars/recur_tests/ex_set4.ics b/calendars/recur_tests/ex_set4.ics new file mode 100644 index 0000000..64e785d --- /dev/null +++ b/calendars/recur_tests/ex_set4.ics @@ -0,0 +1,83 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 4 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monthly on the third to the last day of the month, forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970928T090000 +RRULE:FREQ=MONTHLY;BYMONTHDAY=-3 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monthly on the 2nd and 15th of the month for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=2,15 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every 18 months on the 10th thru 15th of the month for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970910T090000 +RRULE:FREQ=MONTHLY;INTERVAL=18;COUNT=10;BYMONTHDAY=10,11,12,13,14,15 +END:VEVENT +END:VCALENDAR +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every Tuesday, every other month +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=MONTHLY;INTERVAL=2;BYDAY=TU +END:VEVENT +END:VCALENDAR +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Yearly in June and July for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970610T090000 +RRULE:FREQ=YEARLY;COUNT=10;BYMONTH=6,7 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every other year on January, February, and March for 10 occurrences +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970310T090000 +RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3 +END:VEVENT +END:VCALENDAR diff --git a/calendars/recur_tests/ex_set5.ics b/calendars/recur_tests/ex_set5.ics new file mode 100644 index 0000000..862a743 --- /dev/null +++ b/calendars/recur_tests/ex_set5.ics @@ -0,0 +1,81 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 5 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every 3rd year on the 1st, 100th and 200th day for 10 occurrences: +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970101T090000 +RRULE:FREQ=YEARLY;INTERVAL=3;COUNT=10;BYYEARDAY=1,100,200 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every 20th Monday of the year, forever: +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970519T090000 +RRULE:FREQ=YEARLY;BYDAY=20MO +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Monday of week number 20 (where the default start of the week is Monday), forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970512T090000 +RRULE:FREQ=YEARLY;BYWEEKNO=20;BYDAY=MO +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every Thursday in March, forever: +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970313T090000 +RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=TH +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every Thursday, but only during June, July, and August, forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970605T090000 +RRULE:FREQ=YEARLY;BYDAY=TH;BYMONTH=6,7,8 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every Friday the 13th, forever +STATUS:CONFIRMED +DURATION:PT1H30M +EXDATE;TZID=US/Eastern:19970902T090000 +RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13 +END:VEVENT +END:VCALENDAR diff --git a/calendars/recur_tests/ex_set6.ics b/calendars/recur_tests/ex_set6.ics new file mode 100644 index 0000000..5fde900 --- /dev/null +++ b/calendars/recur_tests/ex_set6.ics @@ -0,0 +1,62 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:recur example set 6 +PRODID:-//Apple Computer\, Inc//iCal 2.0//EN +X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD +X-WR-TIMEZONE:US/Pacific +CALSCALE:GREGORIAN +METHOD:PUBLISH + +BEGIN:VTIMEZONE +TZID:US/Pacific +LAST-MODIFIED:20081210T165454Z +BEGIN:STANDARD +DTSTART:20081102T090000 +TZOFFSETTO:-0800 +TZOFFSETFROM:+0000 +TZNAME:PST +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20090308T010000 +TZOFFSETTO:-0700 +TZOFFSETFROM:-0800 +TZNAME:PDT +END:DAYLIGHT +END:VTIMEZONE + +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:The first Saturday that follows the first Sunday of the month, forever +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970913T090000 +RRULE:FREQ=MONTHLY;BYDAY=SA;BYMONTHDAY=7,8,9,10,11,12,13 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +DTSTAMP:20020918T224617Z +SUMMARY:Every four years, the first Tuesday after a Monday in November, + forever (U.S. Presidential Election day): +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19961105T090000 +RRULE:FREQ=YEARLY;INTERVAL=4;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8 +END:VEVENT +BEGIN:VEVENT +DTSTAMP:20020918T224617Z +SUMMARY:The 3rd instance into the month of one of Tuesday, Wednesday or Thursday, for the next 3 months +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970904T090000 +RRULE:FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3 +END:VEVENT +BEGIN:VEVENT +DTSTAMP:20020918T224617Z +SUMMARY:The 2nd to last weekday of the month +STATUS:CONFIRMED +DURATION:PT1H30M +DTSTART;TZID=US/Eastern:19970929T090000 +RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2 +END:VEVENT +END:VCALENDAR diff --git a/functions/ical_parser.php b/functions/ical_parser.php index e6d5b22..ce1f6b6 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -148,7 +148,7 @@ foreach ($cal_filelist as $cal_key=>$filename) { $location = ''; $url = ''; $type = ''; - $wkst = 'SU'; + $wkst = 'MO'; $except_dates = array(); $except_times = array(); diff --git a/functions/init/cpaths.php b/functions/init/cpaths.php index bcf2c11..dd6ae45 100644 --- a/functions/init/cpaths.php +++ b/functions/init/cpaths.php @@ -28,3 +28,4 @@ if (isset($user_template["$cpath"])){ if (isset($phpiCal_config->more_webcals) && is_array($phpiCal_config->more_webcals[$cpath])){ $list_webcals = array_merge($phpiCal_config->list_webcals, $phpiCal_config->more_webcals["$cpath"]); } +$phpiCal_config->setProperty('calendar_path',$calendar_path);
\ No newline at end of file diff --git a/functions/parse/end_vevent.php b/functions/parse/end_vevent.php index eb78ee3..88f94fa 100644 --- a/functions/parse/end_vevent.php +++ b/functions/parse/end_vevent.php @@ -242,7 +242,7 @@ $next_date_time handles those instances within a $freq_type */ #echo "<pre>$summary\n\tstart mArray time:".date("Ymd his",$mArray_begin)."\n\tnext_range_unixtime:".date("Ymd his",$next_range_unixtime)."\n\tend range time ".date("Ymd his",$end_range_unixtime)."\n"; $recur_data = array(); while ($next_range_unixtime <= $end_range_unixtime && $count > 0) { - $year = date('Y', $next_range_unixtime); + $year = date("Y", $next_range_unixtime); $month = date('m', $next_range_unixtime); $time = mktime(12,0,0,$month,date("d",$start_unixtime),$year); switch ($freq_type){ @@ -253,16 +253,17 @@ while ($next_range_unixtime <= $end_range_unixtime && $count > 0) { add_recur(expand_byday($next_range_unixtime)); break; case 'month': - $times = expand_bymonthday(array($time)); + if(!empty($bymonthday)) $time = mktime(12,0,0,$month,1,$year); + $times = expand_bymonthday(array($time));#echo "\n $month exp bymonthday";dump_times($times); foreach($times as $time){ add_recur(expand_byday($time)); } break; case 'year': $times = expand_bymonth($time); #echo "exp bymonth";dump_times($times); - $times = expand_byweekno($times); #echo "exp bymonth";dump_times($times); - $times = expand_byyearday($times); #echo "exp bymonth";dump_times($times); - $times = expand_bymonthday($times); #echo "exp bymonthday";dump_times($times); + $times = expand_byweekno($times); #echo "exp byweekno";dump_times($times); + $times = expand_byyearday($times); #echo "exp byyearday";dump_times($times); + $times = expand_bymonthday($times); #echo "\nexp bymonthday";dump_times($times); foreach($times as $time){ add_recur(expand_byday($time)); } diff --git a/functions/parse/recur_functions.php b/functions/parse/recur_functions.php index e805e42..daf7399 100644 --- a/functions/parse/recur_functions.php +++ b/functions/parse/recur_functions.php @@ -27,53 +27,61 @@ 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); /*BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS*/ $times = restrict_bymonth($times,$freq); - $times = restrict_byweekno($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);#echo "restrict_bysetpos"; if($start_date_unixtime > $mArray_begin) $times[] = $start_date_unixtime; + $times = restrict_bysetpos($times,$freq);#echo "restrict_bysetpos"; $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; + if(isset($time) && !in_array($time, $recur_data) && + !in_array($date, $except_dates) && $time >= $start_date_unixtime && $date <= $until_date){ + $count--; #echo "\n.$count\n"; + if($time >= $mArray_begin && + $time <= $mArray_end + && $count >= 0 + ) $recur_data[] = $time; } } +#dump_times($recur_data); return; } function expand_bymonth($time){ - global $bymonth, $year, $start_unixtime; + global $bymonth, $byweekno, $bymonthday, $year, $start_unixtime, $freq_type; + if(!empty($byweekno)) return $times; if(empty($bymonth)) $bymonth = array(date("m", $start_unixtime)); + $d = date("d",$start_unixtime); + if (!empty($bymonthday)) $d = 1; foreach ($bymonth as $m){ - $time = mktime(12,0,0,$m,date("d",$start_unixtime),$year); #echo "exm:".date("Ymd",$time)."\n"; + $time = mktime(12,0,0,$m,$d,$year); #echo "exm:".date("Ymd",$time)."\n"; $times[] = $time; } return $times; } function expand_byweekno($times){ - global $byweekno, $year; + global $byweekno, $year, $freq_type, $wkst, $wkst3char; + # byweekno is only used when repeat is yearly + # when it's set, the input times are irrelevant + # it also needs a byday. + if ($freq_type != 'year') return $times; if (empty($byweekno)) return $times; - $py = $year-1; - $ny = $year+1; - foreach($times as $time){ - foreach($byweekno as $weekno){ - if($yearday >= 0) $day = strtotime("Jan 1 $year +$weekno weeks"); - else $day = strtotime("Jan 1 $year $weekno weeks"); - if(date("Y",$day == $year)) $new_times[] = $day; - } - } + $total_weeks = date("W",mktime(12,0,0,12,24,$year) ) +1; + $w1_start = strtotime("this $wkst3char", mktime(12,0,0,1,1,$year) ); + foreach($byweekno as $weekno){ + if($weekno < 0) $weekno = $weekno + $total_weeks; + #echo "\n $wkst3char w1st:".date("Ymd", $w1_start)." ".date("Ymd", mktime(12,0,0,1,1,$year))." weekno:$weekno"; + $new_times[] = strtotime("+".(($weekno-1)*7)."days",$w1_start); + } + #dump_times($new_times); return $new_times; } @@ -82,13 +90,15 @@ function expand_byyearday($times){ if (empty($byyearday)) return $times; $py = $year-1; $ny = $year+1; + $new_times = array(); foreach($times as $time){ foreach($byyearday as $yearday){ - if($yearday > 0) $day = strtotime("Dec 31 $py +$yearday days"); - else $day = strtotime("Jan 1 $ny $yearday days"); + if($yearday > 0){ $day = strtotime("+$yearday days Dec 31, $py");#echo "\n".date("Ymd",$day)." = +$yearday days Dec 31, $py"; + }else $day = strtotime("Jan 1 $ny $yearday days"); if(date("Y",$day == $year)) $new_times[] = $day; } - } + } +# dump_times($new_times); return $new_times; } @@ -107,7 +117,7 @@ function expand_bymonthday($times){ } function expand_byday($time){ - global $freq_type, $byday, $wkst3char, $year, $month, $start_unixtime,$summary; + global $freq_type, $byday, $bymonth,$byweekno, $wkst3char, $year, $month, $start_unixtime, $summary; if (empty($byday)) return array($time); $times = array(); $the_sunday = dateOfWeek(date("Ymd",$time), $wkst3char); @@ -119,7 +129,7 @@ function expand_byday($time){ [2] => 4 number [3] => TH day abbr */ - ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); + ereg ('([-\+]{0,1})?([0-9]+)?([A-Z]{2})', $day, $byday_arr); $on_day = two2threeCharDays($byday_arr[3]); switch($freq_type){ case 'week': @@ -128,17 +138,28 @@ function expand_byday($time){ $times[] = $next_date_time; break; case 'month': + $time = mktime(12,0,0,$month,1,$year); case 'year': - $week_arr = array(1,2,3,4,5); - 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; + if(empty($byweekno)){ + $week_arr = array(1,2,3,4,5); + 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); + if($freq_type == 'year' && empty($bymonth)){ + $month_start = mktime(12,0,0,1,0,$year); + $month_end = mktime(12,0,0,1,1,$year+1); + } + foreach($week_arr as $week){ + #echo "<pre>$summary ".$byday_arr[1].$week.$on_day." st:".date("Ymd",$month_start)." t:".date("Ymd",$time)."\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; + } + }else{ + # byweekno should act like freq_type = week + $next_date_time = strtotime("this $on_day",strtotime($the_sunday)) + (12 * 60 * 60); + $times[] = $next_date_time; } break; default: @@ -152,8 +173,8 @@ function expand_byday($time){ function restrict_bymonth($times,$freq=''){ - global $bymonth; - if (empty($bymonth)) return $times; + global $bymonth, $byyearday; + if (empty($bymonth) || !empty($byyearday)) return $times; $new_times=array(); foreach ($times as $time){ if(in_array(date("m", $time), $bymonth)) $new_times[] = $time; @@ -179,8 +200,9 @@ function restrict_byyearday($times,$freq=''){ if(date("L",$time)) $yearday += 1; } $yearday_arr[] = $yearday; - } - if(in_array(date("z", $time), $yearday_arr)) $new_times[] = $time; + } + # date(z,$time) gives 0 for Jan 1 + if(in_array((date("z", $time)+1), $yearday_arr)) $new_times[] = $time; } return $new_times; } @@ -217,12 +239,12 @@ function restrict_byday($times,$freq=''){ } function restrict_bysetpos($times,$freq=''){ - global $rrule_array, $bysetpos; + global $bysetpos; if(empty($bysetpos)) return $times; - $new_times=array(); - $n = count($times); + sort($times); + $new_times=array(); foreach($bysetpos as $setpos){ - $new_times[] = array_slice($times, $setpos, 1); + $new_times[] = implode('',array_slice($times, $setpos, 1)); } return $new_times; } @@ -231,7 +253,7 @@ function restrict_bysetpos($times,$freq=''){ function dump_times($times){ global $summary; echo "<pre>$summary times:"; - var_dump($times); + #var_dump($times); foreach($times as $time) echo "\ndate:".date("Ymd his",$time); echo "</pre>"; } diff --git a/functions/template.php b/functions/template.php index b6e1e2d..ed73672 100644 --- a/functions/template.php +++ b/functions/template.php @@ -946,7 +946,7 @@ class Page { } else { $start2 = date($timeFormat_small, $val['start_unixtime']); if ($type == 'large') { - $switch['EVENT'] .= '<div class="V9"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; + @$switch['EVENT'] .= '<div class="V9"><img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$event_calno.'.gif" alt="" width="9" height="9" border="0" />'; $switch['EVENT'] .= openevent($daylink, $cal_time, $uid, $val, $month_event_lines, 10, 'ps3', "$start2 ").''; $switch['EVENT'] .= (isset($val['location']) && $val['location'] != '') ? "<br />".$val['location']."<br />" : ''; $switch['EVENT'] .= '</div>'; |