Class | TimeZone |
In: |
lib/active_support/values/time_zone.rb
|
Parent: | Object |
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.
US_ZONES | = | /US|Arizona|Indiana|Hawaii|Alaska/ | A regular expression that matches the names of all time zones in the USA. |
name | [R] | |
utc_offset | [R] |
Locate a specific time zone object. If the argument is a string, it is interpreted to mean the name of the timezone to locate. If it is a numeric value it is either the hour offset, or the second offset, of the timezone to find. (The first one with that offset will be returned.) Returns nil if no such time zone is known to the system.
Create a new TimeZone object with the given name and offset. The offset is the number of seconds that this time zone is offset from UTC (GMT). Seconds were chosen as the offset unit because that is the unit that Ruby uses to represent time zone offsets (see Time#utc_offset).
A convenience method for returning a collection of TimeZone objects for time zones in the USA.
Compare this time zone to the parameter. The two are comapred first on their offsets, and then by name.
Returns the offset of this time zone as a formatted string, of the format "+HH:MM". If the offset is zero, this returns the empty string. If colon is false, a colon will not be inserted into the result.