Module: Icalendar::Values::TimeWithZone

Included in:
DateTime, Time
Defined in:
lib/icalendar/values/time_with_zone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tz_utcObject (readonly)

Returns the value of attribute tz_utc.



10
11
12
# File 'lib/icalendar/values/time_with_zone.rb', line 10

def tz_utc
  @tz_utc
end

Instance Method Details

#initialize(value, params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/icalendar/values/time_with_zone.rb', line 12

def initialize(value, params = {})
  @tz_utc = params['tzid'] == 'UTC'

  if defined?(ActiveSupport) && !params['tzid'].nil?
    tzid = params['tzid'].is_a?(::Array) ? params['tzid'].first : params['tzid']
    zone = ActiveSupport::TimeZone[tzid]
    value = ActiveSupport::TimeWithZone.new nil, zone, value unless zone.nil?
    super value, params
  else
    super
  end
end

#params_icalObject



25
26
27
28
# File 'lib/icalendar/values/time_with_zone.rb', line 25

def params_ical
  ical_params.delete 'tzid' if tz_utc
  super
end