class Icalendar::Timezone
Public Class Methods
new()
click to toggle source
Calls superclass method
Icalendar::Component.new
# File lib/icalendar/timezone.rb, line 44 def initialize super 'timezone' end
Public Instance Methods
daylight_for(local)
click to toggle source
# File lib/icalendar/timezone.rb, line 91 def daylight_for(local) possible = daylights.map do |day| schedule = IceCube::Schedule.new(day.dtstart.to_time) do |s| day.rrule.each do |rule| s.add_recurrence_rule IceCube::Rule.from_ical(rule.value_ical) end day.rdate.each do |date| s.add_recurrence_time date.to_time end end [schedule.previous_occurrence(local.to_time), day] end possible.sort_by(&:first).last end
offset_for_local(local)
click to toggle source
# File lib/icalendar/timezone.rb, line 55 def offset_for_local(local) standard = standard_for local daylight = daylight_for local if standard.nil? && daylight.nil? "+00:00" elsif daylight.nil? standard.last.tzoffsetto elsif standard.nil? daylight.last.tzoffsetto else sdst = standard.first ddst = daylight.first if sdst > ddst standard.last.tzoffsetto else daylight.last.tzoffsetto end end end
standard_for(local)
click to toggle source
# File lib/icalendar/timezone.rb, line 76 def standard_for(local) possible = standards.map do |std| schedule = IceCube::Schedule.new(std.dtstart.to_time) do |s| std.rrule.each do |rule| s.add_recurrence_rule IceCube::Rule.from_ical(rule.value_ical) end std.rdate.each do |date| s.add_recurrence_time date.to_time end end [schedule.previous_occurrence(local.to_time), std] end possible.sort_by(&:first).last end
valid?(strict = false)
click to toggle source
Calls superclass method
Icalendar::HasProperties#valid?
# File lib/icalendar/timezone.rb, line 48 def valid?(strict = false) daylights.empty? && standards.empty? and return false daylights.all? { |d| d.valid? strict } or return false standards.all? { |s| s.valid? strict } or return false super end