Exemple #1
0
 /**
  * Gets the next tag after this tag
  *
  * @return PinholeDateTag the next tag after this tag or null if there is
  *                         no next tag.
  */
 public function next()
 {
     $returned_tag = null;
     switch ($this->name) {
         case 'date':
             $date = new SwatDate($this->value);
             $date->addDays(1);
             $value = $date->formatLikeIntl('yyyy-MM-dd');
             break;
         case 'week':
             if (ctype_digit($this->value)) {
                 $value = $this->value < 52 ? $this->value + 1 : null;
             } else {
                 // beginning of next week
                 $start_date = new SwatDate($this->value);
                 $start_date->addDays(7 - $start_date->getDayOfWeek());
                 $value = $start_date->formatLikeIntl('yyyy-MM-dd');
             }
             break;
         case 'year':
             $value = $this->value + 1;
             break;
         case 'month':
             $value = $this->value < 12 ? $this->value + 1 : null;
             break;
         case 'day':
             $value = $this->value < 31 ? $this->value + 1 : null;
             break;
         default:
             $value = null;
             break;
     }
     if ($value !== null) {
         $string = sprintf('%s.%s=%s', self::NS, $this->name, $value);
         $tag = new PinholeDateTag();
         if ($tag->parse($string, $this->db, $this->instance) !== false) {
             $returned_tag = $tag;
         }
     }
     return $returned_tag;
 }