Sha256: bf8cec4bb02df5000d71aca2bed035ba732d88b2537ae0371d5e6b753cf1994a

Contents?: true

Size: 1.56 KB

Versions: 60

Compression:

Stored size: 1.56 KB

Contents

module RiCal
  #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
  #
  # RequireTimezones collects the timezones used by a given calendar component or set of calendar components
  # For each timezone we collect it's id, and the earliest and latest times which reference the zone
  class RequiredTimezones #:nodoc:
    
    
    # A required timezone represents a single timezone and the earliest and latest times which reference it.
    class RequiredTimezone #:nodoc:
      
      attr_reader :first_time, :last_time, :timezone
      
      def initialize(tzid)
        @timezone = RiCal::Component::TZInfoTimezone.new(TZInfo::Timezone.get(tzid))
      end
      
      def tzid
        @timezone.identifier
      end
      
      def add_datetime(date_time)
        if @first_time 
          @first_time = date_time if date_time < @first_time
        else
          @first_time = date_time
        end
        if @last_time 
          @last_time = date_time if date_time > @last_time
        else
          @last_time = date_time
        end
      end
    end
    
    def required_timezones
      @required_zones ||= {}
    end
    
    def required_zones
      required_timezones.values
    end
    
    def export_to(export_stream)
      required_zones.each do |z|
        tzinfo_timezone =z.timezone
        tzinfo_timezone.export_local_to(export_stream, z.first_time, z.last_time)
      end
    end
    
    def add_datetime(date_time, tzid)
      (required_timezones[tzid] ||= RequiredTimezone.new(tzid)).add_datetime(date_time)
    end
  end
end

Version data entries

60 entries across 60 versions & 8 rubygems

Version Path
demingfactor-ri_cal-0.10.0 lib/ri_cal/required_timezones.rb
demingfactor-ri_cal-0.9.0 lib/ri_cal/required_timezones.rb
ebeigarts-ri_cal-0.8.1 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.10 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.11 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.3 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.4 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.5 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.6 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.7 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.8 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.0.9 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.5.0 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.5.1 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.5.2 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.5.3 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.6.0 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.6.1 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.6.2 lib/ri_cal/required_timezones.rb
rubyredrick-ri_cal-0.6.3 lib/ri_cal/required_timezones.rb