Beispiel #1
0
 /**
  * Processes the array of $relative_days to $base and removes any
  * which are not within the scope of our rule.
  */
 public function WithinScope($base, $relative_days)
 {
     //$base=array( '_text' => '20111104T190000', '_epoch' => 1320404400, '_yy' => 2011, '_mo' => 11, '_dd' => 4, '_hh' => 19, '_mi' => 0, '_ss' => 0, '_tz' => NULL, '_wkst' => NULL, )
     //$relative_days=array ( -1 => -1, );
     /*
             var_export($base);
             echo "<p>";
             var_export($relative_days);
             echo "</p>";
             echo "<hr>";
     */
     $ok_days = array();
     $ptr = $this->_current;
     //echo sprintf("<br> WithinScope: Processing list of %d days relative to %s", count($relative_days), $base->Render() );
     foreach ($relative_days as $day => $v) {
         $test = new iCalDate($base);
         //找出該月天數
         $days_in_month = $test->DaysInMonth();
         //echo sprintf("<br> WithinScope: Testing for day %d based on %s, with %d days in month", $day, $test->Render(), $days_in_month );
         if ($day > $days_in_month) {
             $test->SetMonthDay($days_in_month);
             $test->AddDays(1);
             $day -= $days_in_month;
             $test->SetMonthDay($day);
         } else {
             if ($day < 1) {
                 $test->SetMonthDay(1);
                 $test->AddDays(-1);
                 $days_in_month = $test->DaysInMonth();
                 $day += $days_in_month;
                 $test->SetMonthDay($day);
             } else {
                 $test->SetMonthDay($day);
             }
         }
         //echo sprintf("<br> WithinScope: Testing if %s is within scope", count($relative_days), $test->Render() );
         if (isset($this->_part['UNTIL']) && $test->GreaterThan($this->_part['UNTIL'])) {
             $this->_finished = true;
             return $ok_days;
         }
         // if ( $this->_current >= 0 && $test->LessThan($this->_dates[$this->_current]) ) continue;
         if (!$test->LessThan($this->_first)) {
             //echo sprintf("<br> WithinScope: Looks like %s is within scope", $test->Render() );
             $ok_days[$day] = $test;
             $ptr++;
         }
         if (isset($this->_part['COUNT']) && $ptr >= $this->_part['COUNT']) {
             $this->_finished = true;
             return $ok_days;
         }
     }
     return $ok_days;
 }
Beispiel #2
0
 /**
  * Processes the array of $relative_days to $base and removes any
  * which are not within the scope of our rule.
  */
 function WithinScope($base, $relative_days)
 {
     $ok_days = array();
     $ptr = $this->_current;
     //    dbg_error_log( "RRule", " WithinScope: Processing list of %d days relative to %s", count($relative_days), $base->Render() );
     foreach ($relative_days as $day => $v) {
         $test = new iCalDate($base);
         $days_in_month = $test->DaysInMonth();
         //      dbg_error_log( "RRule", " WithinScope: Testing for day %d based on %s, with %d days in month", $day, $test->Render(), $days_in_month );
         if ($day > $days_in_month) {
             $test->SetMonthDay($days_in_month);
             $test->AddDays(1);
             $day -= $days_in_month;
             $test->SetMonthDay($day);
         } else {
             if ($day < 1) {
                 $test->SetMonthDay(1);
                 $test->AddDays(-1);
                 $days_in_month = $test->DaysInMonth();
                 $day += $days_in_month;
                 $test->SetMonthDay($day);
             } else {
                 $test->SetMonthDay($day);
             }
         }
         //      dbg_error_log( "RRule", " WithinScope: Testing if %s is within scope", count($relative_days), $test->Render() );
         if (isset($this->_part['UNTIL']) && $test->GreaterThan($this->_part['UNTIL'])) {
             $this->_finished = true;
             return $ok_days;
         }
         // if ( $this->_current >= 0 && $test->LessThan($this->_dates[$this->_current]) ) continue;
         if (!$test->LessThan($this->_first)) {
             //        dbg_error_log( "RRule", " WithinScope: Looks like %s is within scope", $test->Render() );
             $ok_days[$day] = $test;
             $ptr++;
         }
         if (isset($this->_part['COUNT']) && $ptr >= $this->_part['COUNT']) {
             $this->_finished = true;
             return $ok_days;
         }
     }
     return $ok_days;
 }