aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-09-23 00:24:38 +0000
committerjwangen <jwangen>2002-09-23 00:24:38 +0000
commita06d621069cc8843a1bba0920e202a0ad8d74797 (patch)
treed0a32ed70f13968bc22327654bde9d02ce87c2fb
parentdecb14081931b6b9f33adcdd8436d38ed8de6e43 (diff)
downloadphpicalendar-a06d621069cc8843a1bba0920e202a0ad8d74797.tar.gz
phpicalendar-a06d621069cc8843a1bba0920e202a0ad8d74797.tar.bz2
phpicalendar-a06d621069cc8843a1bba0920e202a0ad8d74797.zip
recurring daily should work now
-rw-r--r--calendars/default.ics39
-rw-r--r--config.inc.php4
-rw-r--r--ical_parser.php141
-rw-r--r--init.inc.php22
4 files changed, 105 insertions, 101 deletions
diff --git a/calendars/default.ics b/calendars/default.ics
index 8f10dd4..d49b0d2 100644
--- a/calendars/default.ics
+++ b/calendars/default.ics
@@ -6,38 +6,38 @@ X-WR-TIMEZONE;VALUE=TEXT:US/Pacific
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
+DTSTART;TZID=US/Pacific:20020822T170000
SEQUENCE:3
+UID:488045FC-CB94-11D6-9F54-003065C59510
DTSTAMP:20020919T050934Z
SUMMARY:Stef in town
DTEND;TZID=US/Pacific:20020822T200000
-DTSTART;TZID=US/Pacific:20020822T170000
-UID:488045FC-CB94-11D6-9F54-003065C59510
END:VEVENT
BEGIN:VEVENT
+DTSTART;TZID=US/Pacific:20020918T121500
SEQUENCE:1
+UID:48804C17-CB94-11D6-9F54-003065C59510
DTSTAMP:20020919T050934Z
SUMMARY:This is a space \n\n\nOption return and a really long line of
text that will be inserted into the event text box. Let's all see what
really happens when iCals start being real.
-DTSTART;TZID=US/Pacific:20020918T121500
-UID:48804C17-CB94-11D6-9F54-003065C59510
DURATION:PT2H
END:VEVENT
BEGIN:VEVENT
SEQUENCE:3
-UID:4880521A-CB94-11D6-9F54-003065C59510
DTSTAMP:20020919T050934Z
SUMMARY:Recurring Monthly
-DTSTART;TZID=US/Pacific:20020919T120000
DTEND;TZID=US/Pacific:20020919T133000
+UID:4880521A-CB94-11D6-9F54-003065C59510
+DTSTART;TZID=US/Pacific:20020919T120000
RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=19
END:VEVENT
BEGIN:VEVENT
SEQUENCE:2
DTSTAMP:20020919T050934Z
SUMMARY:Recurring Weekly
-DTSTART;TZID=US/Pacific:20020920T120000
UID:48805838-CB94-11D6-9F54-003065C59510
+DTSTART;TZID=US/Pacific:20020920T120000
DURATION:PT1H30M
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=FR
END:VEVENT
@@ -45,8 +45,8 @@ BEGIN:VEVENT
SEQUENCE:3
DTSTAMP:20020919T050934Z
SUMMARY:Recurring Daily
-DTSTART;TZID=US/Pacific:20020921T100000
UID:48805D10-CB94-11D6-9F54-003065C59510
+DTSTART;TZID=US/Pacific:20020921T100000
DURATION:PT1H30M
RRULE:FREQ=DAILY;INTERVAL=1
END:VEVENT
@@ -54,46 +54,55 @@ BEGIN:VEVENT
SEQUENCE:4
DTSTAMP:20020919T050934Z
SUMMARY:Monthly UNTIL 5 times
-UID:48806191-CB94-11D6-9F54-003065C59510
DTSTART;TZID=US/Pacific:20020919T140000
+UID:48806191-CB94-11D6-9F54-003065C59510
DURATION:PT1H30M
RRULE:FREQ=MONTHLY;COUNT=5;INTERVAL=1;BYMONTHDAY=19
END:VEVENT
BEGIN:VEVENT
SEQUENCE:11
-DTSTART;TZID=US/Pacific:20020919T160000
DTSTAMP:20020919T050934Z
SUMMARY:Monthly UNTiL date
-UID:488065F8-CB94-11D6-9F54-003065C59510
DTEND;TZID=US/Pacific:20020919T180000
+DTSTART;TZID=US/Pacific:20020919T160000
+UID:488065F8-CB94-11D6-9F54-003065C59510
RRULE:FREQ=MONTHLY;UNTIL=20021223T075959;INTERVAL=1;BYMONTHDAY=19
END:VEVENT
BEGIN:VEVENT
SEQUENCE:7
DTSTAMP:20020919T050934Z
SUMMARY:Every two weeks on certain days
-UID:48806A14-CB94-11D6-9F54-003065C59510
-STATUS:CONFIRMED
DTSTART;TZID=US/Pacific:20020920T150000
+STATUS:CONFIRMED
+UID:48806A14-CB94-11D6-9F54-003065C59510
DURATION:PT1H30M
RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR
END:VEVENT
BEGIN:VEVENT
SEQUENCE:5
-UID:48806EB9-CB94-11D6-9F54-003065C59510
DTSTAMP:20020919T051005Z
SUMMARY:Montly all day
+UID:48806EB9-CB94-11D6-9F54-003065C59510
RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=19,20,21
DTSTART;VALUE=DATE:20020919
DTEND;VALUE=DATE:20020920
END:VEVENT
BEGIN:VEVENT
SEQUENCE:3
-UID:488073A9-CB94-11D6-9F54-003065C59510
DTSTAMP:20020919T055403Z
SUMMARY:Yearly all day
+UID:488073A9-CB94-11D6-9F54-003065C59510
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=9
DTSTART;VALUE=DATE:20020918
DTEND;VALUE=DATE:20020919
END:VEVENT
+BEGIN:VEVENT
+SEQUENCE:3
+DTSTAMP:20020922T213437Z
+SUMMARY:Recurring every 3 days
+DTSTART;TZID=US/Central:20020929T100000
+UID:0D5B7786-CE73-11D6-8DC2-0003930896FC
+DURATION:PT1H30M
+RRULE:FREQ=DAILY;INTERVAL=3
+END:VEVENT
END:VCALENDAR
diff --git a/config.inc.php b/config.inc.php
index 9feef21..a8fd6e2 100644
--- a/config.inc.php
+++ b/config.inc.php
@@ -5,8 +5,8 @@ $fullpath = "webcal://"; // what iCal file are we using
$calendar_path = "./calendars"; // path to directory with calendars
$default_view = "day"; // default view for calendars = "day", "week", "month"
$default_cal = "Home"; // filename of calendar without .ics
-$language = "English"; // Language support - "English", "Polish", "German", "French"
-$week_start_day = "Tuesday"; // Day of the week your week starts on
+$language = "English"; // Language support - "English", "Polish", "German"
+$week_start_day = "Sunday"; // Day of the week your week starts on
$time_format = "12" // Enter "12" for 12 hour clock, "24" for 24 hour clock (military, european)
?> \ No newline at end of file
diff --git a/ical_parser.php b/ical_parser.php
index 38e8bf4..c376ea0 100644
--- a/ical_parser.php
+++ b/ical_parser.php
@@ -8,40 +8,7 @@
include("./init.inc.php");
include("./functions/date_add.php");
-
-// dateOfWeek() takes a date in Ymd and a day of week as iCal knows them (ie: SU, MO, TU, etc)
-// and returns the date of that day. This function may be specific to WEEKLY recurring events.
-
-function dateOfWeek($Ymd, $day) {
- global $week_start_day;
- $timestamp = strtotime($Ymd);
- $sunday = strtotime((date("w",$timestamp)==0 ? "$week_start_day" : "last $week_start_day"), $timestamp);
- if ($day == "SU") $day_longer = "sun";
- elseif ($day == "MO") $day_longer = "mon";
- elseif ($day == "TU") $day_longer = "tue";
- elseif ($day == "WE") $day_longer = "wed";
- elseif ($day == "TH") $day_longer = "thu";
- elseif ($day == "FR") $day_longer = "fri";
- elseif ($day == "SA") $day_longer = "sat";
- return date("Ymd",strtotime($day_longer,$sunday));
-}
-
-// function to compare to dates in Ymd and return the number of weeks that differ between them
-// requires dateOfWeek()
-function weekCompare($now, $then) {
- global $week_start_day;
- $day = substr($week_start_day, 0, 2);
- $sun_now = dateOfWeek($now, $day);
- $sun_then = dateOfWeek($then, $day);
- $seconds_now = strtotime($sun_now);
- $seconds_then = strtotime($sun_then);
- $diff_seconds = $seconds_now - $seconds_then;
- $diff_minutes = $diff_seconds/60;
- $diff_hours = $diff_minutes/60;
- $diff_days = round($diff_hours/24);
- $diff_weeks = $diff_days/7;
- return $diff_weeks;
-}
+include("./functions/date_functions.php");
$day_array = array ("0700", "0730", "0800", "0830", "0900", "0930", "1000", "1030", "1100", "1130", "1200", "1230", "1300", "1330", "1400", "1430", "1500", "1530", "1600", "1630", "1700", "1730", "1800", "1830", "1900", "1930", "2000", "2030", "2100", "2130", "2200", "2230", "2300", "2330");
@@ -225,6 +192,7 @@ foreach($contents as $line) {
$end = $end_of_vevent;
do {
$start_date = date("Ymd", $start);
+// writes to $master array here
$master_array[($start_date)][("0001")]["event_text"][] = "$summary";
$start = ($start + (24*3600));
} while ($start < $end);
@@ -234,45 +202,47 @@ foreach($contents as $line) {
}
// Let's take care of recurring events that are not all day events
- // Nothing is here yet, Jared seems to way to play, so I'll let him do these... muahahahaha.
+ // DAILY and WEEKLY recurrences seem to work fine. Need feedback.
+ // Known bug, doesn't look at UNTIL or COUNT yet.
} else {
- // handling weekly events here, maybe it can be more general, but for now it handles weekly only
- if ($rrule_array["FREQ"] == "WEEKLY") {
- // again, $parse_to_year is set to January 10 of the upcoming year
- $parse_to_year_time = mktime(0,0,0,1,10,($this_year + 1));
- $start_date_time = strtotime($start_date);
-
- // initializing my range. it takes noticeable time to process the entire year so lets only process
- // what we're looking at. We start out initializing for the year, but hopefully we won't do that.
- $start_range_time = $start_date_time;
- $end_range_time = $parse_to_year_time;
-
- // depending on which view we're looking at, we do one month or one week
- // one day is more difficult, I think, so I wrapped that into the week. We'll have to
- // add another case for "year" once that's added.
- if ($current_view == "month") {
- $start_range_time = strtotime("$this_year-$this_month-01");
- $end_range_time = strtotime("+1 month +1 week", $start_range_time);
- } else {
- $start_range_time = strtotime("$this_year-$this_month-$this_day");
- $end_range_time = strtotime("+1 week", $start_range_time);
- }
+ // again, $parse_to_year is set to January 10 of the upcoming year
+ $parse_to_year_time = mktime(0,0,0,1,10,($this_year + 1));
+ $start_date_time = strtotime($start_date);
+
+ // initializing my range. it takes noticeable time to process the entire year so lets only process
+ // what we're looking at. We start out initializing for the year, but hopefully we won't do that.
+ $start_range_time = $start_date_time;
+ $end_range_time = $parse_to_year_time;
+
+ // depending on which view we're looking at, we do one month or one week
+ // one day is more difficult, I think, so I wrapped that into the week. We'll have to
+ // add another case for "year" once that's added.
+ if ($current_view == "month") {
+ $start_range_time = strtotime("$this_year-$this_month-01");
+ $end_range_time = strtotime("+1 month +1 week", $start_range_time);
+ } else {
+ $start_range_time = strtotime(dateOfWeek($getdate, substr($week_start_day, 0, 2)));
+ $end_range_time = strtotime("+1 week", $start_range_time);
+ }
+
+ // If the $end_range_time is less than the $start_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) {
+
+ // 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;
+
+ // initialze the time we will increment
+ $next_range_time = $start_range_time;
- // If the $end_range_time is less than the $start_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 at the $start_range and go until we hit the end of our range.
+ while ($next_range_time >= $start_range_time && $next_range_time <= $end_range_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;
-
- // initialze the time we will increment
- $next_range_time = $start_range_time;
-
- // start at the $start_range and go week by week until we hit the end of our range.
- while ($next_range_time >= $start_range_time && $next_range_time <= $end_range_time) {
-
+ // handling WEEKLY events here
+ if ($rrule_array["FREQ"] == "WEEKLY") {
+
// use weekCompare to see if we even have this event this week
if (weekCompare(date("Ymd",$next_range_time), $start_date) % $number == 0) {
$interval = $number;
@@ -287,8 +257,8 @@ foreach($contents as $line) {
// written by the master data writer (hence the > instead of >=) otherwise we can special case these
// before, the first one would get entered twice and show up twice
// $next_date can fall up to a week behind $next_range_time because of how dateOfWeek works
-// writes to $master array here // so we have to check this again. It uses $except_dates so it doesn't add to $master_array
- // on days that have been deleted by the user
+ // so we have to check this again. It uses $except_dates so it doesn't add to $master_array
+// writes to $master array here // on days that have been deleted by the user
$master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length);
}
}
@@ -296,12 +266,33 @@ foreach($contents as $line) {
$interval = 1;
}
$next_range_time = strtotime("+$interval week", $next_range_time);
+
+ // handling DAILY events here
+ } elseif ($rrule_array["FREQ"] == "DAILY") {
+
+ //print dayCompare(date("Ymd",$next_range_time), $start_date)."<br>";
+ //print $next_range_time." - ".date("Y-m-d",$next_range_time)."<br>";
+
+ // use dayCompare to see if we even have this event this day
+ if (dayCompare(date("Ymd",$next_range_time), $start_date) % $number == 0) {
+ $interval = $number;
+ $next_date = date("Ymd", $next_range_time);
+
+ if (strtotime($next_date) > $start_date_time && !in_array($next_date, $except_dates)) {
+// writes to $master array here // same general concept as the WEEKLY recurrence
+ $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length);
+ }
+ } else {
+ $interval = 1;
+ }
+ $next_range_time = strtotime("+$interval day", $next_range_time);
+
+ // anything else we need to end the loop
+ } else {
+ $next_range_time = $end_range_time + 100;
}
+
}
-
- } else {
-// writes to $master array here
- $master_array[($start_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length);
}
}
}
diff --git a/init.inc.php b/init.inc.php
index 5a5bb96..8ee815c 100644
--- a/init.inc.php
+++ b/init.inc.php
@@ -3,21 +3,25 @@
if(phpversion() >= "4.2.0")
{
- extract($HTTP_POST_VARS);
extract($HTTP_GET_VARS);
+ extract($HTTP_POST_VARS);
}
include('./config.inc.php');
// define supported languages
-if ($language == "German") {
- include "languages/german.inc.php";
-} elseif ($language == "Polish") {
- include "languages/polish.inc.php";
-} elseif ($language == "French") {
- include "languages/french.inc.php";
-} else {
- include "languages/english.inc.php";
+switch ($language) {
+ case "German":
+ include("./languages/german.inc.php");
+ break;
+ case "Polish":
+ include("./languages/polish.inc.php");
+ break;
+ case "French":
+ include("./languages/french.inc.php");
+ break;
+ default:
+ include("./languages/english.inc.php");
}
// $cal_displayname is $cal_filename with occurrences of "32" replaced with " "

© 2014-2024 Faster IT GmbH | imprint | privacy policy