function getRepetitiveInstances($from_date, $to_date)
 {
     $instances = array();
     if ($this->isRepetitive()) {
         $res = $this->forwardRepDate($from_date);
         $ref_date = $res['date'];
         $top_repeat_num = $this->getRepeatNum() - $res['count'];
         $last_repeat = $this->getRepeatEnd() instanceof DateTimeValue ? new DateTimeValue($this->getRepeatEnd()->getTimestamp()) : null;
         if ($this->getRepeatNum() > 0 && $top_repeat_num <= 0 || $last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
             return array();
         }
         $info = array();
         foreach ($this->getColumns() as $col) {
             $info[$col] = $this->getColumnValue($col);
         }
         foreach ($this->getObject()->getColumns() as $col) {
             $info[$col] = $this->getObject()->getColumnValue($col);
         }
         $event = new ProjectEvent();
         $event->setFromAttributes($info);
         $event->setStart(new DateTimeValue($this->getStart()->getTimestamp()));
         $event->setDuration(new DateTimeValue($this->getDuration()->getTimestamp()));
         $event->setId($this->getId());
         $event->setNew(false);
         $event->setInvitations($this->getInvitations());
         if (!$event->getRepeatH() > 0) {
             $instances[] = $event;
         }
         $num_repetitions = 0;
         while ($ref_date->getTimestamp() < $to_date->getTimestamp()) {
             if (!$event->getStart() instanceof DateTimeValue) {
                 return $instances;
             }
             $diff = $ref_date->getTimestamp() - $event->getStart()->getTimestamp();
             $event->setStart(new DateTimeValue($ref_date->getTimestamp()));
             if ($event->getDuration() instanceof DateTimeValue) {
                 $event->getDuration()->advance($diff);
             }
             $info = array();
             foreach ($event->getColumns() as $col) {
                 $info[$col] = $event->getColumnValue($col);
             }
             foreach ($event->getObject()->getColumns() as $col) {
                 $info[$col] = $event->getObject()->getColumnValue($col);
             }
             $new_event = new ProjectEvent();
             $new_event->setFromAttributes($info);
             $new_event->setId($event->getId());
             $new_event->setNew(false);
             $new_event->setInvitations($event->getInvitations());
             $new_due_date = null;
             $new_st_date = null;
             if ($event->getStart() instanceof DateTimeValue) {
                 $new_st_date = new DateTimeValue($event->getStart()->getTimestamp());
             }
             if ($event->getDuration() instanceof DateTimeValue) {
                 $new_due_date = new DateTimeValue($event->getDuration()->getTimestamp());
             }
             if ($event->getRepeatD() > 0) {
                 if ($new_st_date instanceof DateTimeValue) {
                     $new_st_date = $new_st_date->add('d', $event->getRepeatD());
                 }
                 if ($new_due_date instanceof DateTimeValue) {
                     $new_due_date = $new_due_date->add('d', $event->getRepeatD());
                 }
                 $ref_date->add('d', $event->getRepeatD());
             } else {
                 if ($event->getRepeatM() > 0) {
                     if ($new_st_date instanceof DateTimeValue) {
                         $new_st_date = $new_st_date->add('M', $event->getRepeatM());
                     }
                     if ($new_due_date instanceof DateTimeValue) {
                         $new_due_date = $new_due_date->add('M', $event->getRepeatM());
                     }
                     $ref_date->add('M', $event->getRepeatM());
                 } else {
                     if ($event->getRepeatY() > 0) {
                         if ($new_st_date instanceof DateTimeValue) {
                             $new_st_date = $new_st_date->add('y', $event->getRepeatY());
                         }
                         if ($new_due_date instanceof DateTimeValue) {
                             $new_due_date = $new_due_date->add('y', $event->getRepeatY());
                         }
                         $ref_date->add('y', $event->getRepeatY());
                     } else {
                         if ($event->getRepeatH() > 0) {
                             $ordinal = 'first ';
                             switch ($event->getRepeatWnum()) {
                                 case 1:
                                     $ordinal = "first ";
                                     break;
                                 case 2:
                                     $ordinal = "second ";
                                     break;
                                 case 3:
                                     $ordinal = "third ";
                                     break;
                                 case 4:
                                     $ordinal = "fourth ";
                                     break;
                             }
                             $days = array("0" => 'sunday ', "1" => 'monday ', "2" => 'tuesday ', "3" => 'wednesday ', "4" => 'thursday ', "5" => 'friday ', "6" => 'saturday ');
                             $day_name = $days[$event->getRepeatDow() - 1];
                             if ($new_st_date instanceof DateTimeValue) {
                                 //set first day of the month
                                 $new_st_date->setDay(1);
                                 //date string
                                 $new_st_date_string = date("c", $new_st_date->getTimestamp());
                                 //go to the fixed day
                                 $new_st_date_fixed = new DateTime(date("c", strtotime($ordinal . $day_name . " of " . $new_st_date_string)));
                                 $new_st_date = new DateTimeValue($new_st_date_fixed->getTimestamp());
                             }
                             if ($new_due_date instanceof DateTimeValue) {
                                 //set first day of the month
                                 $new_due_date->setDay(1);
                                 //date string
                                 $new_due_date_string = date("c", $new_due_date->getTimestamp());
                                 //go to the fixed day
                                 $new_due_date_fixed = new DateTime(date("c", strtotime($ordinal . $day_name . " of " . $new_due_date_string)));
                                 $new_due_date = new DateTimeValue($new_due_date_fixed->getTimestamp());
                             }
                             $ref_date->add('M', $event->getRepeatMjump());
                         }
                     }
                 }
             }
             if ($new_st_date instanceof DateTimeValue) {
                 $new_event->setStart($new_st_date);
             }
             if ($new_due_date instanceof DateTimeValue) {
                 $new_event->setDuration($new_due_date);
             }
             $num_repetitions++;
             if ($top_repeat_num > 0 && $top_repeat_num == $num_repetitions) {
                 break;
             }
             if ($last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
                 break;
             }
             $instances[] = $new_event;
             $event = $new_event;
         }
     }
     return $instances;
 }