setByDay() public method

MO indicates Monday; TU indicates Tuesday; WE indicates Wednesday; TH indicates Thursday; FR indicates Friday; SA indicates Saturday; SU indicates Sunday. Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of the specific day within the MONTHLY or YEARLY RRULE. For example, within a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday within the month, whereas -1MO represents the last Monday of the month. If an integer modifier is not present, it means all days of this type within the specified frequency. For example, within a MONTHLY rule, MO represents all Mondays within the month. ------------------------------------------- DO NOT MIX DAYS AND DAYS WITH MODIFIERS. This is not supported. -------------------------------------------
public setByDay ( array $byDay )
$byDay array Array of days of the week
 public function testGetString()
 {
     $this->rule->setFreq('YEARLY');
     $this->rule->setCount(2);
     $this->rule->setInterval(2);
     $this->rule->setBySecond(array(30));
     $this->rule->setByMinute(array(10));
     $this->rule->setByHour(array(5, 15));
     $this->rule->setByDay(array('SU', 'WE'));
     $this->rule->setByMonthDay(array(16, 22));
     $this->rule->setByYearDay(array(201, 203));
     $this->rule->setByWeekNumber(array(29, 32));
     $this->rule->setByMonth(array(7, 8));
     $this->rule->setBySetPosition(array(1, 3));
     $this->rule->setWeekStart('TU');
     $this->rule->setExDates(array('20140607', '20140620T010000Z', '20140620T010000'));
     $this->assertEquals('FREQ=YEARLY;COUNT=2;INTERVAL=2;BYSECOND=30;BYMINUTE=10;BYHOUR=5,15;BYDAY=SU,WE;BYMONTHDAY=16,22;BYYEARDAY=201,203;BYWEEKNO=29,32;BYMONTH=7,8;BYSETPOS=1,3;WKST=TU;EXDATE=20140607,20140620T010000Z,20140620T010000', $this->rule->getString());
 }
 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);
 }