18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/icalendar/values/time_with_zone.rb', line 18
def initialize(value, params = {})
params = Icalendar::DowncasedHash(params)
@tz_utc = params['tzid'] == 'UTC'
x_tz_info = params.delete 'x-tz-info'
offset_value = unless params['tzid'].nil?
tzid = params['tzid'].is_a?(::Array) ? params['tzid'].first : params['tzid']
if defined?(ActiveSupport::TimeZone) &&
defined?(ActiveSupportTimeWithZoneAdapter) &&
(tz = ActiveSupport::TimeZone[tzid])
ActiveSupportTimeWithZoneAdapter.new(nil, tz, value)
elsif !x_tz_info.nil?
offset = x_tz_info.offset_for_local(value).to_s
if value.respond_to?(:change)
value.change offset: offset
else
::Time.new value.year, value.month, value.day, value.hour, value.min, value.sec, offset
end
end
end
super((offset_value || value), params)
end
|