Exemple #1
0
  public function getRrule() {
    if (($rrule = $this->getProperty('RRULE')) === null) {
      return null;
    }
    $data = Vpdi::decodeTextList($rrule->value(), ';');
    foreach($data as $d) {
      list($name, $value) = explode('=', $d);
      $name = strtolower($name);
      $property[$name]=$value;
    }
    $freq = strtolower($property['freq']);
    if (!in_array($freq, $this->frequency)) return null;

    $return = array();

    switch ($freq)  {
      case 'weekly':
        $days = '0000000';
        if(!is_null($property['byday'])) {
          $byday = Vpdi::decodeTextList($property['byday']);
          foreach($byday as $day) {
            $index = date('w', strtotime($this->weekDays[strtolower($day)]));
            $days[$index] = '1';
          }
        }
        $return['repeat_days'] = $days;
        break;
      case 'monthly' :
        if(!is_null($property['byday'])) {
          $freq = 'monthlybyday';
        } else {
          $freq = 'monthlybydate';
        }
        break;
    }

    $return['freq'] = $freq;
    if(is_numeric($property['interval'])) {
      $return['interval'] = $property['interval'];
    } else {
      $return['interval'] = 1;
    }

    if(!is_null($property['count'])) {
      $return['count'] = $property['count'];
    } elseif(!is_null($property['until'])) {
      $return['until'] = Vpdi::decodeDate($property['until']);
    }

    // Exceptions
    $return['exdates'] = null;
    if (($exdates = $this->getPropertiesByName('EXDATE')) != null) {
      foreach($exdates as $exdate) {
        $return['exdates'][] = new Of_Date($exdate->value());
      } 
    }
    return $return;
  }
Exemple #2
0
 /**
  * Returns a DateTime object set to the value of the BDAY property
  * 
  * @access public
  * @return DateTime
  */
 public function getBday() {
   if (($bday = $this->getValue('BDAY')) === null) {
     return null;
   }
   return Vpdi::decodeDate($bday);
 }