Sha256: a09d8db94ee06c18492b4cd0674ef7f2d151ed8717a71fcdb67c9ef7ba3e7d01

Contents?: true

Size: 1.62 KB

Versions: 55

Compression:

Stored size: 1.62 KB

Contents

module RiCal
  module CoreExtensions #:nodoc:
    module Time #:nodoc:
      #- ©2009 Rick DeNatale
      #- All rights reserved. Refer to the file README.txt for the license
      #
      # Provides a tzid attribute for ::Time and ::DateTime
      module TzidAccess
        # The tzid attribute is used by RiCal, it should be a valid timezone identifier within a calendar,
        # :floating to indicate a floating time, or nil to use the default timezone in effect
        #
        # See PropertyValue::DateTime#default_tzid= and Component::Calendar#tzid=
        attr_accessor :tzid

        # Convenience method, sets the tzid and returns the receiver
        def set_tzid(time_zone_identifier)
          self.tzid = time_zone_identifier
          self
        end

        # Predicate indicating whether or not the instance represents a floating time
        def has_floating_timezone?
          tzid == :floating
        end

      end
    end
  end

  module TimeWithZoneExtension #:nodoc:
    def tzid
      utc? ? "UTC" : time_zone.tzinfo.identifier
    end

    # Predicate indicating whether or not the instance represents a floating time
    def has_floating_timezone?
      false
    end

    def to_ri_cal_date_time_value(timezone_finder=nil)
      ::RiCal::PropertyValue::DateTime.new(timezone_finder, :params => {"TZID" => tzid}, :value => strftime("%Y%m%dT%H%M%S"))
    end
    alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_time_value
    alias_method :to_ri_cal_occurrence_list_value, :to_ri_cal_date_time_value
  end
end

if RiCal::TimeWithZone
  RiCal::TimeWithZone.class_eval {include RiCal::TimeWithZoneExtension}
end

Version data entries

55 entries across 55 versions & 8 rubygems

Version Path
demingfactor-ri_cal-0.10.0 lib/ri_cal/core_extensions/time/tzid_access.rb
demingfactor-ri_cal-0.9.0 lib/ri_cal/core_extensions/time/tzid_access.rb
ebeigarts-ri_cal-0.8.1 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.10 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.11 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.8 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.9 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.5.0 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.5.1 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.5.2 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.5.3 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.6.0 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.6.1 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.6.2 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.6.3 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.7.0 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.7.1 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.7.2 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.7.4 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.7.5 lib/ri_cal/core_extensions/time/tzid_access.rb