class method
self.find_zone!
Ruby on Rails 4.1.16
Since v3.1.12Signature
self.find_zone!(time_zone)
Returns a TimeZone instance or nil, or raises an ArgumentError for invalid timezones.
Parameters
-
time_zonereq
Source
# File activesupport/lib/active_support/core_ext/time/zones.rb, line 55
def find_zone!(time_zone)
if !time_zone || time_zone.is_a?(ActiveSupport::TimeZone)
time_zone
else
# lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone)
unless time_zone.respond_to?(:period_for_local)
time_zone = ActiveSupport::TimeZone[time_zone] || TZInfo::Timezone.get(time_zone)
end
# Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone
if time_zone.is_a?(ActiveSupport::TimeZone)
time_zone
else
ActiveSupport::TimeZone.create(time_zone.name, nil, time_zone)
end
end
rescue TZInfo::InvalidTimezoneIdentifier
raise ArgumentError, "Invalid Timezone: #{time_zone}"
end
Defined in activesupport/lib/active_support/core_ext/time/zones.rb line 55
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Time