Sha256: 33c7f76573c5513bbafc82572d8f94648d12cad57b1ea94e76e9939f94b9d805

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 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
      end
    end
  end

  module TimeWithZoneExtension #:nodoc:
    def tzid
      time_zone.tzid.identifier
    end
  end
end

if Object.const_defined?(:ActiveSupport)
  as = Object.const_get(:ActiveSupport)
  if as.const_defined?(:TimeWithZone)
    twz = as.const_get(:TimeWithZone)
    twz.class_eval {include RiCal::TimeWithZoneExtension}
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubyredrick-ri_cal-0.0.3 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.4 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.5 lib/ri_cal/core_extensions/time/tzid_access.rb
rubyredrick-ri_cal-0.0.6 lib/ri_cal/core_extensions/time/tzid_access.rb