- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (0)
- 2.0.3 (0)
- 2.1.0 (26)
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
A value object representing a time zone. A time zone is simply a named offset (in seconds) from GMT. Note that two time zone objects are only equivalent if they have both the same offset, and the same name.
A TimeZone instance may be used to convert a Time value to the corresponding time zone.
The class also includes #all, which returns a list of all TimeZone objects.
Constants
US_ZONES = /US|Arizona|Indiana|Hawaii|Alaska/
Attributes
[R] | name | |
[R] | utc_offset |
Rails v2.1.0 has built-in time-zone support
Rails versions as of 2.1.0 have basic timezone support built-in to the Time object. However, to get a list of all the timezones you need to install the tzinfo gem.
TZInfo::Country.all.sort_by { |c| c.name }.each do |c| puts c.name # E.g. Norway c.zones.each do |z| puts "\t#{z.friendly_identifier(true)} (#{z.identifier})" # E.g. Oslo (Europe/Oslo) end end
TZInfo::TimeZone.get(identifier) returns a TimeZone -object by the identifier.