class headers for everything
authorChuck Hagenbuch <chuck@horde.org>
Thu, 29 Jan 2009 22:12:53 +0000 (17:12 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 29 Jan 2009 22:13:04 +0000 (17:13 -0500)
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/DayName.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/DayPortion.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Fortnight.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Hour.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Minute.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Month.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/MonthName.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Second.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Time.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Week.php
framework/Date_Parser/lib/Horde/Date/Parser/Locale/Base/Repeater/Weekend.php

index 0486a4d..d93399c 100644 (file)
@@ -1,44 +1,47 @@
-class Chronic::RepeaterDayName < Chronic::Repeater #:nodoc:
-  DAY_SECONDS = 86400 # (24 * 60 * 60)
-  
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_DayName extends Horde_Date_Parser_Locale_Base_Repeater
+{
+    // (24 * 60 * 60)
+    const DAY_SECONDS = 86400;
+
   def next(pointer)
     super
-    
+
     direction = pointer == :future ? 1 : -1
-    
+
     if !@current_day_start
       @current_day_start = Time.construct(@now.year, @now.month, @now.day)
       @current_day_start += direction * DAY_SECONDS
 
       day_num = symbol_to_number(@type)
-      
+
       while @current_day_start.wday != day_num
         @current_day_start += direction * DAY_SECONDS
       end
     else
       @current_day_start += direction * 7 * DAY_SECONDS
     end
-    
+
     Chronic::Span.new(@current_day_start, @current_day_start + DAY_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     pointer = :future if pointer == :none
     self.next(pointer)
   end
-  
+
   def width
     DAY_SECONDS
   end
-  
+
   def to_s
     super << '-dayname-' << @type.to_s
   end
-  
+
   private
-  
+
   def symbol_to_number(sym)
     lookup = {:sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6}
     lookup[sym] || raise("Invalid symbol specified")
index c854933..0f3ef72 100644 (file)
@@ -1,12 +1,14 @@
-class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_DayPortion extends Horde_Date_Parser_Locale_Base_Repeater
+{
   @@morning = (6 * 60 * 60)..(12 * 60 * 60) # 6am-12am
   @@afternoon = (13 * 60 * 60)..(17 * 60 * 60) # 1pm-5pm
   @@evening = (17 * 60 * 60)..(20 * 60 * 60) # 5pm-8pm
   @@night = (20 * 60 * 60)..(24 * 60 * 60) # 8pm-12pm
-  
+
   def initialize(type)
     super
-    
+
     if type.kind_of? Integer
       @range = (@type * 60 * 60)..((@type + 12) * 60 * 60)
     else
@@ -21,12 +23,12 @@ class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
     end
     @range || raise("Range should have been set by now")
   end
-  
+
   def next(pointer)
     super
-    
+
     full_day = 60 * 60 * 24
-    
+
     if !@current_span
       now_seconds = @now - Time.construct(@now.year, @now.month, @now.day)
       if now_seconds < @range.begin
@@ -51,7 +53,7 @@ class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
           range_start = Time.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
         end
       end
-      
+
       @current_span = Chronic::Span.new(range_start, range_start + (@range.end - @range.begin))
     else
       case pointer
@@ -62,21 +64,21 @@ class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
       end
     end
   end
-  
+
   def this(context = :future)
     super
-    
+
     range_start = Time.construct(@now.year, @now.month, @now.day) + @range.begin
     @current_span = Chronic::Span.new(range_start, range_start + (@range.end - @range.begin))
   end
-  
+
   def offset(span, amount, pointer)
     @now = span.begin
     portion_span = self.next(pointer)
     direction = pointer == :future ? 1 : -1
     portion_span + (direction * (amount - 1) * Chronic::RepeaterDay::DAY_SECONDS)
   end
-  
+
   def width
     @range || raise("Range has not been set")
     return @current_span.width if @current_span
@@ -86,7 +88,7 @@ class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
       @range.end - @range.begin
     end
   end
-  
+
   def to_s
     super << '-dayportion-' << @type.to_s
   end
index 058fbb9..0460d75 100644 (file)
@@ -1,9 +1,11 @@
-class Chronic::RepeaterFortnight < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Fortnight extends Horde_Date_Parser_Locale_Base_Repeater
+{
   FORTNIGHT_SECONDS = 1_209_600 # (14 * 24 * 60 * 60)
-  
+
   def next(pointer)
     super
-    
+
     if !@current_fortnight_start
       case pointer
       when :future
@@ -22,15 +24,15 @@ class Chronic::RepeaterFortnight < Chronic::Repeater #:nodoc:
       direction = pointer == :future ? 1 : -1
       @current_fortnight_start += direction * FORTNIGHT_SECONDS
     end
-    
+
     Chronic::Span.new(@current_fortnight_start, @current_fortnight_start + FORTNIGHT_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     pointer = :future if pointer == :none
-    
+
     case pointer
     when :future
       this_fortnight_start = Time.construct(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
@@ -49,7 +51,7 @@ class Chronic::RepeaterFortnight < Chronic::Repeater #:nodoc:
       Chronic::Span.new(this_fortnight_start, this_fortnight_end)
     end
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     span + direction * amount * FORTNIGHT_SECONDS
@@ -58,7 +60,7 @@ class Chronic::RepeaterFortnight < Chronic::Repeater #:nodoc:
   def width
     FORTNIGHT_SECONDS
   end
-  
+
   def to_s
     super << '-fortnight'
   end
index f38a3f8..f13e385 100644 (file)
@@ -1,9 +1,14 @@
-class Chronic::RepeaterHour < Chronic::Repeater #:nodoc:
-  HOUR_SECONDS = 3600 # 60 * 60
-  
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Hour extends Horde_Date_Parser_Locale_Base_Repeater
+{
+    /**
+     * 60 * 60
+     */
+    const HOUR_SECONDS = 3600;
+
   def next(pointer)
     super
-    
+
     if !@current_hour_start
       case pointer
       when :future
@@ -15,13 +20,13 @@ class Chronic::RepeaterHour < Chronic::Repeater #:nodoc:
       direction = pointer == :future ? 1 : -1
       @current_hour_start += direction * HOUR_SECONDS
     end
-    
+
     Chronic::Span.new(@current_hour_start, @current_hour_start + HOUR_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :future
       hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
@@ -33,19 +38,19 @@ class Chronic::RepeaterHour < Chronic::Repeater #:nodoc:
       hour_start = Time.construct(@now.year, @now.month, @now.day, @now.hour)
       hour_end = hour_begin + HOUR_SECONDS
     end
-    
+
     Chronic::Span.new(hour_start, hour_end)
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     span + direction * amount * HOUR_SECONDS
   end
-  
+
   def width
     HOUR_SECONDS
   end
-  
+
   def to_s
     super << '-hour'
   end
index 342d3cd..a15da64 100644 (file)
@@ -1,9 +1,11 @@
-class Chronic::RepeaterMinute < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Minute extends Horde_Date_Parser_Locale_Base_Repeater
+{
   MINUTE_SECONDS = 60
-  
+
   def next(pointer = :future)
     super
-    
+
     if !@current_minute_start
       case pointer
       when :future
@@ -15,13 +17,13 @@ class Chronic::RepeaterMinute < Chronic::Repeater #:nodoc:
       direction = pointer == :future ? 1 : -1
       @current_minute_start += direction * MINUTE_SECONDS
     end
-    
+
     Chronic::Span.new(@current_minute_start, @current_minute_start + MINUTE_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :future
       minute_begin = @now
@@ -33,19 +35,19 @@ class Chronic::RepeaterMinute < Chronic::Repeater #:nodoc:
       minute_begin = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
       minute_end = Time.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS
     end
-    
+
     Chronic::Span.new(minute_begin, minute_end)
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     span + direction * amount * MINUTE_SECONDS
   end
-  
+
   def width
     MINUTE_SECONDS
   end
-  
+
   def to_s
     super << '-minute'
   end
index edd89ee..bb3b1b4 100644 (file)
@@ -1,22 +1,24 @@
-class Chronic::RepeaterMonth < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Month extends Horde_Date_Parser_Locale_Base_Repeater
+{
   MONTH_SECONDS = 2_592_000 # 30 * 24 * 60 * 60
   YEAR_MONTHS = 12
-  
+
   def next(pointer)
     super
-    
+
     if !@current_month_start
       @current_month_start = offset_by(Time.construct(@now.year, @now.month), 1, pointer)
     else
       @current_month_start = offset_by(Time.construct(@current_month_start.year, @current_month_start.month), 1, pointer)
     end
-    
+
     Chronic::Span.new(@current_month_start, Time.construct(@current_month_start.year, @current_month_start.month + 1))
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :future
       month_start = Time.construct(@now.year, @now.month, @now.day + 1)
@@ -28,20 +30,20 @@ class Chronic::RepeaterMonth < Chronic::Repeater #:nodoc:
       month_start = Time.construct(@now.year, @now.month)
       month_end = self.offset_by(Time.construct(@now.year, @now.month), 1, :future)
     end
-    
+
     Chronic::Span.new(month_start, month_end)
   end
-  
-  def offset(span, amount, pointer)      
+
+  def offset(span, amount, pointer)
     Chronic::Span.new(offset_by(span.begin, amount, pointer), offset_by(span.end, amount, pointer))
   end
-  
-  def offset_by(time, amount, pointer) 
+
+  def offset_by(time, amount, pointer)
     direction = pointer == :future ? 1 : -1
-    
+
     amount_years = direction * amount / YEAR_MONTHS
     amount_months = direction * amount % YEAR_MONTHS
-    
+
     new_year = time.year + amount_years
     new_month = time.month + amount_months
     if new_month > YEAR_MONTHS
@@ -50,11 +52,11 @@ class Chronic::RepeaterMonth < Chronic::Repeater #:nodoc:
     end
     Time.construct(new_year, new_month, time.day, time.hour, time.min, time.sec)
   end
-  
+
   def width
     MONTH_SECONDS
   end
-  
+
   def to_s
     super << '-month'
   end
index 1f8b748..3b3135a 100644 (file)
@@ -1,9 +1,11 @@
-class Chronic::RepeaterMonthName < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_MonthName extends Horde_Date_Parser_Locale_Base_Repeater
+{
   MONTH_SECONDS = 2_592_000 # 30 * 24 * 60 * 60
-  
+
   def next(pointer)
     super
-    
+
     if !@current_month_begin
       target_month = symbol_to_number(@type)
       case pointer
@@ -35,10 +37,10 @@ class Chronic::RepeaterMonthName < Chronic::Repeater #:nodoc:
         @current_month_begin = Time.construct(@current_month_begin.year - 1, @current_month_begin.month)
       end
     end
-    
+
     cur_month_year = @current_month_begin.year
     cur_month_month = @current_month_begin.month
-    
+
     if cur_month_month == 12
       next_month_year = cur_month_year + 1
       next_month_month = 1
@@ -46,13 +48,13 @@ class Chronic::RepeaterMonthName < Chronic::Repeater #:nodoc:
       next_month_year = cur_month_year
       next_month_month = cur_month_month + 1
     end
-      
+
     Chronic::Span.new(@current_month_begin, Time.construct(next_month_year, next_month_month))
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :past
       self.next(pointer)
@@ -60,21 +62,21 @@ class Chronic::RepeaterMonthName < Chronic::Repeater #:nodoc:
       self.next(:none)
     end
   end
-  
+
   def width
     MONTH_SECONDS
   end
-  
+
   def index
     symbol_to_number(@type)
   end
-  
+
   def to_s
     super << '-monthname-' << @type.to_s
   end
-  
+
   private
-  
+
   def symbol_to_number(sym)
     lookup = {:january => 1,
               :february => 2,
index 6d05545..f55c865 100644 (file)
@@ -1,36 +1,38 @@
-class Chronic::RepeaterSecond < Chronic::Repeater #:nodoc:
-  SECOND_SECONDS = 1 # haha, awesome
-  
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Second extends Horde_Date_Parser_Locale_Base_Repeater
+{
+    const SECOND_SECONDS = 1;
+
   def next(pointer = :future)
     super
-    
+
     direction = pointer == :future ? 1 : -1
-    
+
     if !@second_start
       @second_start = @now + (direction * SECOND_SECONDS)
     else
       @second_start += SECOND_SECONDS * direction
     end
-    
+
     Chronic::Span.new(@second_start, @second_start + SECOND_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     Chronic::Span.new(@now, @now + 1)
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     span + direction * amount * SECOND_SECONDS
   end
-  
+
   def width
     SECOND_SECONDS
   end
-  
+
   def to_s
     super << '-second'
   end
-end
\ No newline at end of file
+end
index f856014..827be4e 100644 (file)
@@ -1,32 +1,35 @@
-class Chronic::RepeaterTime < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Time extends Horde_Date_Parser_Locale_Base_Repeater
+{
+
   class Tick #:nodoc:
     attr_accessor :time
-    
+
     def initialize(time, ambiguous = false)
       @time = time
       @ambiguous = ambiguous
     end
-    
+
     def ambiguous?
       @ambiguous
     end
-    
+
     def *(other)
       Tick.new(@time * other, @ambiguous)
     end
-    
+
     def to_f
       @time.to_f
     end
-    
+
     def to_s
       @time.to_s + (@ambiguous ? '?' : '')
     end
   end
-  
+
   def initialize(time, options = {})
     t = time.gsub(/\:/, '')
-    @type = 
+    @type =
     if (1..2) === t.size
       hours = t.to_i
       hours == 12 ? Tick.new(0 * 60 * 60, true) : Tick.new(hours * 60 * 60, true)
@@ -46,18 +49,18 @@ class Chronic::RepeaterTime < Chronic::Repeater #:nodoc:
       raise("Time cannot exceed six digits")
     end
   end
-  
+
   # 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
   def next(pointer)
     super
-    
+
     half_day = 60 * 60 * 12
     full_day = 60 * 60 * 24
-    
+
     first = false
-    
+
     unless @current_time
       first = true
       midnight = Time.local(@now.year, @now.month, @now.day)
@@ -87,30 +90,30 @@ class Chronic::RepeaterTime < Chronic::Repeater #:nodoc:
           end
         end
       end
-      
+
       @current_time || raise("Current time cannot be nil at this point")
     end
-    
+
     unless first
       increment = @type.ambiguous? ? half_day : full_day
       @current_time += pointer == :future ? increment : -increment
     end
-    
+
     Chronic::Span.new(@current_time, @current_time + width)
   end
-  
+
   def this(context = :future)
     super
-    
+
     context = :future if context == :none
-    
+
     self.next(context)
   end
-  
+
   def width
     1
   end
-  
+
   def to_s
     super << '-time-' << @type.to_s
   end
index ec88ff1..6ce5b35 100644 (file)
@@ -1,9 +1,11 @@
-class Chronic::RepeaterWeek < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Week extends Horde_Date_Parser_Locale_Base_Repeater
+{
   WEEK_SECONDS = 604800 # (7 * 24 * 60 * 60)
-  
+
   def next(pointer)
     super
-    
+
     if !@current_week_start
       case pointer
       when :future
@@ -22,13 +24,13 @@ class Chronic::RepeaterWeek < Chronic::Repeater #:nodoc:
       direction = pointer == :future ? 1 : -1
       @current_week_start += direction * WEEK_SECONDS
     end
-    
+
     Chronic::Span.new(@current_week_start, @current_week_start + WEEK_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :future
       this_week_start = Time.local(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
@@ -52,16 +54,16 @@ class Chronic::RepeaterWeek < Chronic::Repeater #:nodoc:
       Chronic::Span.new(this_week_start, this_week_start + WEEK_SECONDS)
     end
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     span + direction * amount * WEEK_SECONDS
   end
-  
+
   def width
     WEEK_SECONDS
   end
-  
+
   def to_s
     super << '-week'
   end
index f012267..2ddfb15 100644 (file)
@@ -1,9 +1,11 @@
-class Chronic::RepeaterWeekend < Chronic::Repeater #:nodoc:
+<?php
+class Horde_Date_Parser_Locale_Base_Repeater_Weekend extends Horde_Date_Parser_Locale_Base_Repeater
+{
   WEEKEND_SECONDS = 172_800 # (2 * 24 * 60 * 60)
-  
+
   def next(pointer)
     super
-    
+
     if !@current_week_start
       case pointer
       when :future
@@ -21,13 +23,13 @@ class Chronic::RepeaterWeekend < Chronic::Repeater #:nodoc:
       direction = pointer == :future ? 1 : -1
       @current_week_start += direction * Chronic::RepeaterWeek::WEEK_SECONDS
     end
-    
+
     Chronic::Span.new(@current_week_start, @current_week_start + WEEKEND_SECONDS)
   end
-  
+
   def this(pointer = :future)
     super
-    
+
     case pointer
     when :future, :none
       saturday_repeater = Chronic::RepeaterDayName.new(:saturday)
@@ -41,7 +43,7 @@ class Chronic::RepeaterWeekend < Chronic::Repeater #:nodoc:
       Chronic::Span.new(last_saturday_span.begin, last_saturday_span.begin + WEEKEND_SECONDS)
     end
   end
-  
+
   def offset(span, amount, pointer)
     direction = pointer == :future ? 1 : -1
     weekend = Chronic::RepeaterWeekend.new(:weekend)
@@ -49,11 +51,11 @@ class Chronic::RepeaterWeekend < Chronic::Repeater #:nodoc:
     start = weekend.next(pointer).begin + (amount - 1) * direction * Chronic::RepeaterWeek::WEEK_SECONDS
     Chronic::Span.new(start, start + (span.end - span.begin))
   end
-  
+
   def width
     WEEKEND_SECONDS
   end
-  
+
   def to_s
     super << '-weekend'
   end