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_ |
A regular expression that matches the names of all time zones in the USA. |
| Public Attributes | |
|---|---|
| name | |
| utc_ |
|
| Public Methods | |
|---|---|
| <=> | Compare this time zone to the parameter. The two are comapred first on their offsets, and then by name. |
| [] | 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. |
| adjust | Adjust the given time to the time zone represented by self. |
| all | Return an array of all TimeZone objects. There are multiple TimeZone objects per time zone, in many cases, to make it easier for users to find their own time zone. |
| create | Create a new TimeZone instance with the given name and offset. |
| formatted_ |
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. |
| new | Return a TimeZone instance with the given name, or nil if no such TimeZone instance exists. (This exists to support the use of this class with the #composed_of macro.) |
| new | 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). |
| now | Compute and return the current time, in the time zone represented by self. |
| to_ |
Returns a textual representation of this time zone. |
| today | Return the current date in this time zone. |
| unadjust | Reinterprets the given time value as a time in the current time zone, and then adjusts it to return the corresponding time in the local time zone. |
| us_ |
A convenience method for returning a collection of TimeZone objects for time zones in the USA. |
<code/>and<pre/>for code samples.