Class: RiCal::Component::Calendar::TZInfoWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ri_cal/component/calendar.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tzinfo, calendar) ⇒ TZInfoWrapper

:nodoc:



116
117
118
119
# File 'lib/ri_cal/component/calendar.rb', line 116

def initialize(tzinfo, calendar) #:nodoc:
  @tzinfo = tzinfo
  @calendar = calendar
end

Instance Attribute Details

#calendarObject (readonly)

:nodoc:



115
116
117
# File 'lib/ri_cal/component/calendar.rb', line 115

def calendar
  @calendar
end

#tzinfoObject (readonly)

:nodoc:



115
116
117
# File 'lib/ri_cal/component/calendar.rb', line 115

def tzinfo
  @tzinfo
end

Instance Method Details

#identifierObject

:nodoc:



121
122
123
# File 'lib/ri_cal/component/calendar.rb', line 121

def identifier #:nodoc:
  tzinfo.identifier
end

#local_date_time(ruby_time, tzid) ⇒ Object

:nodoc:



125
126
127
# File 'lib/ri_cal/component/calendar.rb', line 125

def local_date_time(ruby_time, tzid) #:nodoc:
  RiCal::PropertyValue::DateTime.new(calendar, :value => ruby_time.strftime("%Y%m%dT%H%M%S"), :params => {'TZID' => tzid})
end

#local_to_utc(utc) ⇒ Object

:nodoc:



133
134
135
# File 'lib/ri_cal/component/calendar.rb', line 133

def local_to_utc(utc) #:nodoc:
  utc_date_time(tzinfo.local_to_utc(utc.to_ri_cal_ruby_value))
end

#rational_utc_offset(local) ⇒ Object



142
143
144
# File 'lib/ri_cal/component/calendar.rb', line 142

def rational_utc_offset(local)
  RiCal.RationalOffset[tzinfo.period_for_local(local, true).utc_total_offset]
end

#utc_date_time(ruby_time) ⇒ Object

:nodoc



129
130
131
# File 'lib/ri_cal/component/calendar.rb', line 129

def utc_date_time(ruby_time) #:nodoc
    RiCal::PropertyValue::DateTime.new(calendar, :value => ruby_time.strftime("%Y%m%dT%H%M%SZ"))
end

#utc_to_local(local) ⇒ Object

:nodoc:



137
138
139
# File 'lib/ri_cal/component/calendar.rb', line 137

def utc_to_local(local) #:nodoc:
  local_date_time(tzinfo.utc_to_local(local.to_ri_cal_ruby_value), tzinfo.identifier)
end