示例#1
0
文件: ical.php 项目: blogfor/king
 }
 // Output event
 echo "BEGIN:VEVENT\r\n";
 echo "UID:" . eo_get_event_uid() . "\r\n";
 echo "STATUS:" . $status . "\r\n";
 echo "DTSTAMP:" . $dtstamp . "\r\n";
 echo "CREATED:" . $created_date . "\r\n";
 echo "LAST-MODIFIED:" . $modified_date . "\r\n";
 if (eo_is_all_day()) {
     echo "DTSTART;VALUE=DATE:" . $start_date . "\r\n";
     echo "DTEND;VALUE=DATE:" . $end_date . "\r\n";
 } else {
     echo "DTSTART:" . $start_date . "\r\n";
     echo "DTEND:" . $end_date . "\r\n";
 }
 if ($reoccurrence_rule = eventorganiser_generate_ics_rrule()) {
     echo "RRULE:" . $reoccurrence_rule . "\r\n";
 }
 if (!empty($schedule_data['exclude'])) {
     $exclude_strings = array();
     foreach ($schedule_data['exclude'] as $exclude) {
         if (!eo_is_all_day()) {
             $vdate = '';
             $exclude->setTimezone($UTC_tz);
             $exclude_strings[] = $exclude->format('Ymd\\THis\\Z');
         } else {
             $vdate = ';VALUE=DATE';
             $exclude_strings[] = $exclude->format('Ymd');
         }
     }
     echo "EXDATE" . $vdate . ":" . implode(',', $exclude_strings) . "\r\n";
示例#2
0
 public function testTimezoneChangeRRULE()
 {
     //When day changes when start date is converted to UTC timezone (for iCal feed)
     //Remember to correct [day] the 'reccurs weekly by [day]', so thats true for UTC timezone.
     wp_cache_set('eventorganiser_timezone', 'America/New_York');
     //Event recurrs every Monday evening in New York (event recurs every Tuesday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 21:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 23:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 21:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;UNTIL=20131231T020000Z", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
     //Now try it the other direction....
     wp_cache_set('eventorganiser_timezone', 'Europe/Moscow');
     //Event recurrs every Monday morning in Moscow (event recurs very Sunday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 01:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 02:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 01:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     //This is a bit of a hack, some php5.2 instances will have an out of date Europe/Moscow timezone details
     //but cannot install the pecl.php.net/timezonedb package. We therefore can't hardcode the until date string
     //as it may be 21:00 or 22:00
     $utc = new DateTimeZone('UTC');
     $until = new DateTime('2013-12-30 01:00', eo_get_blog_timezone());
     $until->setTimezone($utc);
     $until_string = $until->format('Ymd\\THis\\Z');
     //Probably 20131229T210000Z or 20131229T220000Z
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=SU;UNTIL={$until_string}", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
 }
 public function testTimezoneChangeRRULE()
 {
     //When day changes when start date is converted to UTC timezone (for iCal feed)
     //Remember to correct [day] the 'reccurs weekly by [day]', so thats true for UTC timezone.
     wp_cache_set('eventorganiser_timezone', 'America/New_York');
     //Event recurrs every Monday evening in New York (event recurs very Tuesday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 21:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 23:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 21:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;UNTIL=20131231T020000Z", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
     //Now try it the other direction....
     wp_cache_set('eventorganiser_timezone', 'Europe/Moscow');
     //Event recurrs every Monday morning in Moscow (event recurs very Sunday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 01:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 02:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 01:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=SU;UNTIL=20131229T210000Z", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
 }