Sha256: 72cba3cb878948c65f9d628a3cd77174beffe95527a0094e224d8430a7cb355e

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

module RiCal
  #- ©2009 Rick DeNatale
  #- All rights reserved. Refer to the file README.txt for the license
  #
  # FloatingTimezone represents the 'time zone' for a time or date time with no timezone
  # Times with floating timezones are always interpreted in the timezone of the observer
  class FloatingTimezone
    
    def self.identifier #:nodoc:
      nil
    end
    
    def self.tzinfo_timezone #:nodoc:
      nil
    end
    
    # Return the time unchanged #:nodoc:
    def self.utc_to_local(time)
      time.with_floating_timezone.to_ri_cal_date_time_value
    end

    # Return the time unchanged #:nodoc:
    def self.local_to_utc(time)
      time.with_floating_timezone.to_ri_cal_date_time_value
    end
  end
  
  class TimeWithFloatingTimezone #:nodoc:
    def initialize(time) #:nodoc:
      @time = time
    end

    def acts_like_time? #:nodoc:
      true
    end

    def time_zone
      FloatingTimezone #:nodoc:
    end

    def strftime(format) #:nodoc:
      @time.strftime(format)
    end
    
    def with_floating_timezone #:nodoc:
      self
    end

    def to_ri_cal_date_time_value #:nodoc:
      ::RiCal::PropertyValue::DateTime.new(nil, :value => @time, :params => {'TZID' => nil})
    end

    alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_time_value #:nodoc:
    
    def method_missing(selector, *args) #:nodoc:
      @time.send(selector, *args)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyredrick-ri_cal-0.0.2 lib/ri_cal/time_with_floating_timezone.rb