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:


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

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

Instance Attribute Details

#calendarObject (readonly)

:nodoc:


113
114
115
# File 'lib/ri_cal/component/calendar.rb', line 113

def calendar
  @calendar
end

#tzinfoObject (readonly)

:nodoc:


113
114
115
# File 'lib/ri_cal/component/calendar.rb', line 113

def tzinfo
  @tzinfo
end

Instance Method Details

#identifierObject

:nodoc:


119
120
121
# File 'lib/ri_cal/component/calendar.rb', line 119

def identifier #:nodoc:
  tzinfo.identifier
end

#local_date_time(ruby_time, tzid) ⇒ Object

:nodoc:


123
124
125
# File 'lib/ri_cal/component/calendar.rb', line 123

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:


131
132
133
# File 'lib/ri_cal/component/calendar.rb', line 131

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


140
141
142
# File 'lib/ri_cal/component/calendar.rb', line 140

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

#utc_date_time(ruby_time) ⇒ Object

:nodoc


127
128
129
# File 'lib/ri_cal/component/calendar.rb', line 127

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:


135
136
137
# File 'lib/ri_cal/component/calendar.rb', line 135

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