Module: Icalendar::Values::Helpers::TimeWithZone

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#timezone_storeObject (readonly)

Returns the value of attribute timezone_store.



20
21
22
# File 'lib/icalendar/values/helpers/time_with_zone.rb', line 20

def timezone_store
  @timezone_store
end

#tz_utcObject (readonly)

Returns the value of attribute tz_utc.



20
21
22
# File 'lib/icalendar/values/helpers/time_with_zone.rb', line 20

def tz_utc
  @tz_utc
end

Instance Method Details

#__getobj__Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/icalendar/values/helpers/time_with_zone.rb', line 38

def __getobj__
  orig_value = super
  if set_offset?
    orig_value
  else
    new_value = Icalendar::Offset.build(orig_value, ical_params, timezone_store)&.normalized_value
    __setobj__(new_value) unless new_value.nil?
    new_value || orig_value
  end
end

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/icalendar/values/helpers/time_with_zone.rb', line 22

def initialize(value, params = {}, context = {})
  params = Icalendar::DowncasedHash(params)
  context = Icalendar::DowncasedHash(context)
  @tz_utc = params['tzid'] == 'UTC'
  @timezone_store = context['timezone_store']

  offset = Icalendar::Offset.build(value, params, timezone_store)

  unless offset.nil?
    @offset_value = offset.normalized_value
    params['tzid'] = offset.normalized_tzid
  end

  super (@offset_value || value), params, context
end

#params_icalObject



49
50
51
52
# File 'lib/icalendar/values/helpers/time_with_zone.rb', line 49

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