class TimeZone
Ruby on Rails 5.2.8.1
Since v2.2.3The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following:
-
Limit the set of zones provided by TZInfo to a meaningful subset of 134 zones.
-
Retrieve and display zones with a friendlier name (e.g., “Eastern Time (US & Canada)” instead of “America/New_York”).
-
Lazily load TZInfo::Timezone instances only when they’re needed.
-
Create ActiveSupport::TimeWithZone instances via TimeZone’s
local,parse,atandnowmethods.
If you set config.time_zone in the Rails Application, you can access this TimeZone object via Time.zone:
# application.rb: class Application < Rails::Application config.time_zone = 'Eastern Time (US & Canada)' end Time.zone # => #<ActiveSupport::TimeZone:0x514834...> Time.zone.name # => "Eastern Time (US & Canada)" Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
Inherits from
Includes
Constants
Attributes
Methods (defined here)
- # <=>
- # =~
- # at
- # formatted_offset
- # iso8601
- # local
- # local_to_utc
- # now
- # parse
- # period_for_local
- # period_for_utc
- # rfc3339
- # strptime
- # today
- # tomorrow
- # to_s
- # utc_offset
- # utc_to_local
- # yesterday
- self. []
- self. all
- self. country_zones
- self. create
- self. find_tzinfo
- self. new
- self. seconds_to_utc_offset
- self. us_zones
Private methods
(4)
Implementation detail — not part of the public API.
- # parts_to_time
- # time_now
- self. load_country_zones
- self. zones_map
Methods (inherited)
From Object (17)
- # acts_like?
- # blank?
- # deep_dup
- # duplicable?
- # html_safe?
- # in?
- # instance_values
- # instance_variable_names
- # presence
- # presence_in
- # present?
- # to_param
- # to_query
- # try
- # try!
- # unescape
- # with_options