setUntil() public method

Either UNTIL or COUNT may be specified, but UNTIL and COUNT MUST NOT both be specified.
public setUntil ( DateTime $until )
$until DateTime The upper bound of the recurrence.
Beispiel #1
0
 public function testGetStringWithUTC()
 {
     $this->rule->setFreq('DAILY');
     $this->rule->setInterval(1);
     $this->rule->setUntil(new \DateTime('2015-07-10 04:00:00', new \DateTimeZone('America/New_York')));
     $this->assertNotEquals('FREQ=DAILY;UNTIL=20150710T040000Z;INTERVAL=1', $this->rule->getString());
     $this->assertEquals('FREQ=DAILY;UNTIL=20150710T080000Z;INTERVAL=1', $this->rule->getString(Rule::TZ_FIXED));
 }
 public function fromParams($params, $entity_manager)
 {
     $rrule = new RRule();
     $event_data = $params['event'];
     $event_data['is_visible'] = isset($event_data['is_visible']) && $event_data['is_visible'];
     $event_data['is_all_day'] = isset($event_data['is_all_day']) && $event_data['is_all_day'];
     $event_data['is_closed'] = isset($event_data['is_closed']) && $event_data['is_closed'];
     if ($event_data['is_all_day'] || $event_data['is_closed']) {
         $start = new \Datetime($params['event_start_date']);
         $end = new \Datetime($params['event_start_date']);
     } else {
         $start = new \Datetime($event_data['start']);
         $end = new \Datetime($event_data['end']);
     }
     $rrule->setStartDate($start);
     $rrule->setEndDate($end);
     if (isset($params['event_recurrence_rule_custom'])) {
         if (isset($params['event_recurrence_rule_custom']['BYDAY'])) {
             $rrule->setByDay($params['event_recurrence_rule_custom']['BYDAY']);
         }
         if (!empty($params['event_recurrence_rule_custom']['UNTIL'])) {
             $until = clone $start;
             $date = explode('-', $params['event_recurrence_rule_custom']['UNTIL']);
             $until->setDate(intval($date[0]), intval($date[1]), intval($date[2]));
             $rrule->setUntil($until);
         }
         if (isset($params['event_recurrence_rule_custom']['INTERVAL'])) {
             $rrule->setInterval($params['event_recurrence_rule_custom']['INTERVAL']);
         }
     }
     switch ($event_data['recurrence_rule']) {
         case 'CUSTOM':
             // freq rules are in custom fields
             $event_data['is_recurring'] = true;
             $event_data['is_custom_rrule'] = true;
             $rrule->setFreq($params['event_recurrence_rule_custom']['FREQ']);
             break;
         case 'NONE':
             $event_data['is_recurring'] = false;
             $event_data['is_custom_rrule'] = false;
             $rrule->setCount(1);
             break;
         default:
             // freq value is sitting in the recurrence_rule field
             $event_data['is_recurring'] = true;
             $event_data['is_custom_rrule'] = false;
             $rrule->setFreq($event_data['recurrence_rule']);
     }
     if (empty($event_data['title'])) {
         $event_data['title'] = 'New Event';
     }
     if (empty($event_data['category'])) {
         $event_data['category'] = new Category(array('name' => 'None', 'color' => '#ddd000', 'priority' => 9999999999999.0));
     } else {
         $event_data['category'] = $entity_manager->find('\\Hoo\\Model\\Category', intval($event_data['category']));
     }
     $event_data['location'] = $entity_manager->find('\\Hoo\\Model\\Location', intval($event_data['location']));
     $event_data['start'] = $start;
     $event_data['end'] = $end;
     $event_data['recurrence_rule'] = $rrule;
     return $this->fromArray($event_data);
 }