Class: RiCal::Component::TZInfoTimezone::Period
- Defined in:
- lib/ri_cal/component/t_z_info_timezone.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #add_period(this_period) ⇒ Object
- #export_to(export_stream) ⇒ Object
-
#format_rfc2445_offset(seconds) ⇒ Object
:nodoc:.
-
#initialize(which, this_period, prev_period) ⇒ Period
constructor
A new instance of Period.
- #period_local_start(period) ⇒ Object
Constructor Details
#initialize(which, this_period, prev_period) ⇒ Period
Returns a new instance of Period.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 11 def initialize(which, this_period, prev_period) @which = which @onset = period_local_start(this_period) if prev_period @offset_from = format_rfc2445_offset(prev_period.utc_total_offset) else @offset_from = format_rfc2445_offset(this_period.utc_total_offset) end @offset_to = format_rfc2445_offset(this_period.utc_total_offset) @abbreviation = this_period.abbreviation @rdates = [] end |
Instance Method Details
#add_period(this_period) ⇒ Object
28 29 30 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 28 def add_period(this_period) @rdates << period_local_start(this_period) end |
#export_to(export_stream) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 41 def export_to(export_stream) export_stream.puts "BEGIN:#{@which}" export_stream.puts "DTSTART:#{@onset}" export_stream.puts "RDATE:#{@rdates.join(",")}" export_stream.puts "TZOFFSETFROM:#{@offset_from}" export_stream.puts "TZOFFSETTO:#{@offset_to}" export_stream.puts "TZNAME:#{@abbreviation}" export_stream.puts "END:#{@which}" end |
#format_rfc2445_offset(seconds) ⇒ Object
:nodoc:
33 34 35 36 37 38 39 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 33 def format_rfc2445_offset(seconds) #:nodoc: abs_seconds = seconds.abs h = (abs_seconds/3600).floor m = (abs_seconds - (h * 3600))/60 h *= -1 if seconds < 0 sprintf("%+03d%02d", h, m) end |