fix start/now mismatch, remove commented code
authorChuck Hagenbuch <chuck@horde.org>
Tue, 3 Feb 2009 17:34:30 +0000 (12:34 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Tue, 3 Feb 2009 22:33:37 +0000 (17:33 -0500)
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Ordinal.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater.php
framework/Date_Parser/lib/Horde/Date/Parser/Tag.php

index 7e241f5..c243908 100644 (file)
@@ -279,7 +279,7 @@ class Horde_Date_Parser_Locale_Base
 
     public function handle_m_d($month, $day, $timeTokens, $options)
     {
-        $month->start = $this->now;
+        $month->now = $this->now;
         $span = $month->this($options['context']);
 
         $dayStart = new Horde_Date(array('year' => $span->begin->year, 'month' => $span->begin->month, 'day' => $day));
@@ -420,22 +420,6 @@ class Horde_Date_Parser_Locale_Base
 
     public function handle_s_r_p($tokens, $options)
     {
-        $repeater = $tokens[1]->getTag('Repeater');
-
-        /*
-          # span =
-          # case true
-          # when [RepeaterYear, RepeaterSeason, RepeaterSeasonName, RepeaterMonth, RepeaterMonthName, RepeaterWeek].include?(repeater.class)
-          #   self.parse("this hour", :guess => false, :now => @now)
-          # when [RepeaterWeekend, RepeaterDay, RepeaterDayName, RepeaterDayPortion, RepeaterHour].include?(repeater.class)
-          #   self.parse("this minute", :guess => false, :now => @now)
-          # when [RepeaterMinute, RepeaterSecond].include?(repeater.class)
-          #   self.parse("this second", :guess => false, :now => @now)
-          # else
-          #   raise(ChronicPain, "Invalid repeater: #{repeater.class}")
-          # end
-        */
-
         $span = $this->parse('this second', array('guess' => false, 'now' => $this->now));
         return $this->handle_srp($tokens, $span, $options);
     }
@@ -460,7 +444,7 @@ class Horde_Date_Parser_Locale_Base
     public function handle_orr($tokens, $outerSpan, $options)
     {
         $repeater = $tokens[1]->getTag('Repeater');
-        $repeater->start = $outerSpan->begin - 1;
+        $repeater->now = $outerSpan->begin - 1;
         $ordinal = $tokens[0]->getTag('Ordinal')->type;
         $span = null;
 
@@ -507,7 +491,7 @@ class Horde_Date_Parser_Locale_Base
         }
 
         $head = array_shift($repeaters);
-        $head->start = $this->now;
+        $head->now = $this->now;
 
         switch ($grabber->type) {
         case 'last':
@@ -559,7 +543,7 @@ class Horde_Date_Parser_Locale_Base
 
         $head = array_shift($tags);
         $rest = $tags;
-        $head->start = ($pointer == 'future') ? $span->begin : $span->end;
+        $head->now = ($pointer == 'future') ? $span->begin : $span->end;
         $h = $head->this('none');
 
         if ($span->include($h->begin) || $span->include($h->end)) {
index 1b75d49..710f793 100644 (file)
@@ -29,7 +29,7 @@ class Horde_Date_Parser_Locale_Base_Ordinal extends Horde_Date_Parser_Tag
     {
         if (preg_match($this->ordinalDayRegex, $token->word, $matches)) {
             if ($matches[1] <= 31) {
-                /* @TODO FIXME - hardcoded class name */
+                /* FIXME - hardcoded class name */
                 return new Horde_Date_Parser_Locale_Base_OrdinalDay((int)$m[1]);
             }
         }
index c4b1907..b722664 100644 (file)
@@ -115,48 +115,4 @@ class Horde_Date_Parser_Locale_Base_Repeater extends Horde_Date_Parser_Tag
         }
     }
 
-    /*
-  def <=>(other)
-    width <=> other.width
-  end
-    */
-
-    /**
-     * returns the width (in seconds or months) of this repeatable.
-     */
-    public function width()
-    {
-        throw new Horde_Date_Parser_Exception('Repeatable#width must be overridden in subclasses');
-    }
-
-    /**
-     * returns the next occurance of this repeatable.
-     */
-    public function next($pointer)
-    {
-        if (is_null($this->now)) {
-            throw new Horde_Date_Parser_Exception('Start point must be set before calling next()');
-        }
-
-        if (!in_array($pointer, array('future', 'none', 'past'))) {
-            throw new Horde_Date_Parser_Exception("First argument 'pointer' must be one of 'past', 'future', 'none'");
-        }
-    }
-
-    public function this($pointer)
-    {
-        if (is_null($this->now)) {
-            throw new Horde_Date_Parser_Exception('Start point must be set before calling this()');
-        }
-
-        if (!in_array($pointer, array('future', 'none', 'past'))) {
-            throw new Horde_Date_Parser_Exception("First argument 'pointer' must be one of 'past', 'future', 'none'");
-        }
-    }
-
-    public function __toString()
-    {
-        return 'repeater';
-    }
-
 }
index a079640..af46685 100644 (file)
@@ -1,7 +1,10 @@
 <?php
 /**
- * Tokens are tagged with subclassed instances of this class when
- * they match specific criteria
+ */
+
+/**
+ * Tokens are tagged with subclassed instances of this class when they match
+ * specific criteria.
  */
 class Horde_Date_Parser_Tag
 {
@@ -13,9 +16,4 @@ class Horde_Date_Parser_Tag
         $this->type = $type;
     }
 
-    public function start($s)
-    {
-        $this->now = $s;
-    }
-
 }