Module: Icalendar::Values::BetterTimezones

Included in:
Date, DateTime
Defined in:
lib/synchrograph/icalendar_monkey_patches/better_timezones.rb

Constant Summary collapse

WINDOWS_TZID_MAP =
Hash[wz.scan(regex)]

Instance Method Summary collapse

Instance Method Details

#tzinfoObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/synchrograph/icalendar_monkey_patches/better_timezones.rb', line 10

def tzinfo
  return time_zone.tzinfo if self.respond_to? :time_zone

  tzid = ical_params['tzid']
  tzid = tzid.first if tzid and tzid.any?

  if tzid
    return TZInfo::Timezone.get(WINDOWS_TZID_MAP[tzid]) if WINDOWS_TZID_MAP.has_key? tzid
    return TZInfo::Timezone.get(tzid) if TZInfo::Timezone.all_identifiers.include? tzid
  end

  return TZInfo::Timezone.get('Etc/UTC')
end

#value_with_tzObject



24
25
26
# File 'lib/synchrograph/icalendar_monkey_patches/better_timezones.rb', line 24

def value_with_tz
  ActiveSupportTimeWithZoneAdapter.new nil, tzinfo, value
end