public static function Create($FeedURL, $FeedUsername, $FeedPassword, $Summary, $StartDate, $EndDate, $Location, $Description, $RRule = null) { $headers = array(); $headers = \HTTP\HTTPRequests::GetStandardHeaders(); $headers["Content-Type"] = "text/calendar; charset=utf-8"; $headers["Authorization"] = "Basic " . base64_encode($FeedUsername . ":" . $FeedPassword); $headers["If-None-Match"] = "*"; $uid = \Data\Event::GetNewUniqueID(); $content = array(); $content[] = "BEGIN:VCALENDAR"; $content[] = "PRODID:Calico"; $content[] = "VERSION:2.0"; $content[] = "BEGIN:VTIMEZONE"; $content[] = "TZID:America/New_York"; // date_default_timezone_get() $content[] = "X-LIC-LOCATION:America/New_York"; //@todo: Implement Daylight-Savings / Other Timezones, instead of hard coding them. //Verify which one is Daylight, if it has Daylight. //Algorithm -> create a date on June 1st, then set it to December 1st. Check timezones on both. // If they match, there is no DayLight savings. //New idea: nevermind this nonsense, for now. Apparently, not only are date / times a level of insanity (as I already knew), //but timezones + daylight savings times are moving targets. It appears that some countries are randomly trying out Daylight-Savings times. $content[] = "BEGIN:DAYLIGHT"; $content[] = "TZOFFSETFROM:-0500"; $content[] = "TZOFFSETTO:-0400"; $content[] = "TZNAME:EDT"; $content[] = "DTSTART:19700308T020000"; $content[] = "RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3"; $content[] = "END:DAYLIGHT"; $content[] = "BEGIN:STANDARD"; $content[] = "TZOFFSETFROM:-0400"; $content[] = "TZOFFSETTO:-0500"; $content[] = "TZNAME:EST"; $content[] = "DTSTART:19701101T020000"; $content[] = "RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11"; $content[] = "END:STANDARD"; $content[] = "END:VTIMEZONE"; $content = array_merge($content, \Data\Event::BuildVEvent($uid, $Summary, $StartDate, $EndDate, $Location, $Description, time(), time(), time(), $RRule)); //GenerateUID goes in here. $content[] = "END:VCALENDAR"; $url = $FeedURL . "/" . $uid . ".ics"; //@todo: Construct URL (UID) to post to here. $response = \HTTP\HTTPRequests::Put($url, $headers, $content); if (strlen(strstr($response, "HTTP/1.1 201 Created")) > 0) { $etag = \Extract\Extract::GetETag($response); $Event = new Event($url, $FeedUsername, $FeedPassword, $etag, $FeedURL); return $Event; } return null; }