next() public method

returns the next occurance of this repeatable.
public next ( $pointer = 'future' )
Esempio n. 1
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentFortnightStart) {
         switch ($pointer) {
             case 'future':
                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
                 $sundayRepeater->now = $this->now;
                 $nextSundaySpan = $sundayRepeater->next('future');
                 $this->currentFortnightStart = $nextSundaySpan->begin;
                 break;
             case 'past':
                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
                 $sundayRepeater->now = clone $this->now;
                 $sundayRepeater->now->day++;
                 $sundayRepeater->next('past');
                 $sundayRepeater->next('past');
                 $lastSundaySpan = $sundayRepeater->next('past');
                 $this->currentFortnightStart = $lastSundaySpan->begin;
                 break;
         }
     } else {
         $direction = $pointer == 'future' ? 1 : -1;
         $this->currentFortnightStart->add($direction * self::FORTNIGHT_SECONDS);
     }
     return new Horde_Date_Span($this->currentFortnightStart, $this->currentFortnightStart->add(self::FORTNIGHT_SECONDS));
 }
Esempio n. 2
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentWeekStart) {
         switch ($pointer) {
             case 'future':
                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
                 $sundayRepeater->now = $this->now;
                 $nextSundaySpan = $sundayRepeater->next('future');
                 $this->currentWeekStart = $nextSundaySpan->begin;
                 break;
             case 'past':
                 $sundayRepeater = new Horde_Date_Repeater_DayName('sunday');
                 $sundayRepeater->now = clone $this->now;
                 $sundayRepeater->now->day++;
                 $sundayRepeater->next('past');
                 $lastSundaySpan = $sundayRepeater->next('past');
                 $this->currentWeekStart = $lastSundaySpan->begin;
                 break;
         }
     } else {
         $direction = $pointer == 'future' ? 1 : -1;
         $this->currentWeekStart->day += $direction * 7;
     }
     return new Horde_Date_Span($this->currentWeekStart, $this->currentWeekStart->add(array('day' => 7)));
 }
Esempio n. 3
0
 public function this($pointer = 'future')
 {
     parent::next($pointer);
     if ($pointer == 'none') {
         $pointer = 'future';
     }
     return $this->next($pointer);
 }
Esempio n. 4
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentYearStart) {
         $this->currentYearStart = new Horde_Date(array('year' => $this->now->year, 'month' => 1, 'day' => 1));
     }
     $diff = $pointer == 'future' ? 1 : -1;
     $this->currentYearStart->year += $diff;
     return new Horde_Date_Span($this->currentYearStart, $this->currentYearStart->add(array('year' => 1)));
 }
Esempio n. 5
0
File: Time.php Progetto: horde/horde
 /**
  * Return the next past or future Span for the time that this Repeater represents
  *   pointer - Symbol representing which temporal direction to fetch the next day
  *             must be either :past or :future
  */
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     $halfDay = 3600 * 12;
     $fullDay = 3600 * 24;
     $first = false;
     if (!$this->currentTime) {
         $first = true;
         $midnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
         $yesterdayMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1));
         $tomorrowMidnight = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1));
         if ($pointer == 'future') {
             if ($this->ambiguous) {
                 foreach (array($midnight->add($this->type), $midnight->add($halfDay + $this->type), $tomorrowMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) >= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             } else {
                 foreach (array($midnight->add($this->type), $tomorrowMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) >= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             }
         } elseif ($pointer == 'past') {
             if ($this->ambiguous) {
                 foreach (array($midnight->add($halfDay + $this->type), $midnight->add($this->type), $yesterdayMidnight->add($this->type * 2)) as $t) {
                     if ($t->compareDateTime($this->now) <= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             } else {
                 foreach (array($midnight->add($this->type), $yesterdayMidnight->add($this->type)) as $t) {
                     if ($t->compareDateTime($this->now) <= 0) {
                         $this->currentTime = $t;
                         break;
                     }
                 }
             }
         }
         if (!$this->currentTime) {
             throw new Horde_Date_Repeater_Exception('Current time cannot be null at this point');
         }
     }
     if (!$first) {
         $increment = $this->ambiguous ? $halfDay : $fullDay;
         $this->currentTime->sec += $pointer == 'future' ? $increment : -$increment;
     }
     return new Horde_Date_Span($this->currentTime, $this->currentTime->add(1));
 }
Esempio n. 6
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentDayStart) {
         $this->currentDayStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day));
     }
     $direction = $pointer == 'future' ? 1 : -1;
     $this->currentDayStart->day += $direction;
     $end = clone $this->currentDayStart;
     $end->day += 1;
     return new Horde_Date_Span($this->currentDayStart, $end);
 }
Esempio n. 7
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     $direction = $pointer == 'future' ? 1 : -1;
     if (!$this->secondStart) {
         $this->secondStart = clone $this->now;
         $this->secondStart->sec += $direction;
     } else {
         $this->secondStart += $direction;
     }
     $end = clone $this->secondStart;
     $end->sec++;
     return new Horde_Date_Span($this->secondStart, $end);
 }
Esempio n. 8
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentSpan) {
         $nowSeconds = $this->now->hour * 3600 + $this->now->min * 60 + $this->now->sec;
         if ($nowSeconds < $this->range[0]) {
             switch ($pointer) {
                 case 'future':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'sec' => $this->range[0]));
                     break;
                 case 'past':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1, 'sec' => $this->range[0]));
                     break;
             }
         } elseif ($nowSeconds > $this->range[1]) {
             switch ($pointer) {
                 case 'future':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1, 'sec' => $this->range[0]));
                     break;
                 case 'past':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day, 'sec' => $this->range[0]));
                     break;
             }
         } else {
             switch ($pointer) {
                 case 'future':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day + 1, 'sec' => $this->range[0]));
                     break;
                 case 'past':
                     $rangeStart = new Horde_Date(array('year' => $this->now->year, 'month' => $this->now->month, 'day' => $this->now->day - 1, 'sec' => $this->range[0]));
                     break;
             }
         }
         $rangeEnd = $rangeStart->add($this->range[1] - $this->range[0]);
         $this->currentSpan = new Horde_Date_Span($rangeStart, $rangeEnd);
     } else {
         switch ($pointer) {
             case 'future':
                 $this->currentSpan = $this->currentSpan->add(array('day' => 1));
                 break;
             case 'past':
                 $this->currentSpan = $this->currentSpan->add(array('day' => -1));
                 break;
         }
     }
     return $this->currentSpan;
 }
Esempio n. 9
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     if (!$this->currentMonthStart) {
         $targetMonth = $this->_monthNumber($this->type);
         switch ($pointer) {
             case 'future':
                 if ($this->now->month < $targetMonth) {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
                 } else {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year + 1, 'month' => $targetMonth, 'day' => 1));
                 }
                 break;
             case 'none':
                 if ($this->now->month <= $targetMonth) {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
                 } else {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year + 1, 'month' => $targetMonth, 'day' => 1));
                 }
                 break;
             case 'past':
                 if ($this->now->month > $targetMonth) {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year, 'month' => $targetMonth, 'day' => 1));
                 } else {
                     $this->currentMonthStart = new Horde_Date(array('year' => $this->now->year - 1, 'month' => $targetMonth, 'day' => 1));
                 }
                 break;
         }
     } else {
         switch ($pointer) {
             case 'future':
                 $this->currentMonthStart->year++;
                 break;
             case 'past':
                 $this->currentMonthStart->year--;
                 break;
         }
     }
     return new Horde_Date_Span($this->currentMonthStart, $this->currentMonthStart->add(array('month' => 1)));
 }
Esempio n. 10
0
 public function next($pointer = 'future')
 {
     parent::next($pointer);
     throw new Horde_Date_Repeater_Exception('Not implemented');
 }