Bug #5416 » 0001-Document-zone_offset-and-ZoneOffset.patch
lib/time.rb | ||
---|---|---|
class Time
|
||
class << Time
|
||
#
|
||
# A hash of timezones mapped to hour differences from UTC. The
|
||
# set of time zones corresponds to the ones specified by RFC 2822
|
||
# and ISO 8601.
|
||
#
|
||
ZoneOffset = {
|
||
'UTC' => 0,
|
||
# ISO 8601
|
||
... | ... | |
'N' => -1, 'O' => -2, 'P' => -3, 'Q' => -4, 'R' => -5, 'S' => -6,
|
||
'T' => -7, 'U' => -8, 'V' => -9, 'W' => -10, 'X' => -11, 'Y' => -12,
|
||
}
|
||
#
|
||
# Return the number of seconds the specified time zone differs
|
||
# from UTC.
|
||
#
|
||
# Numeric time zones that include minutes, such as
|
||
# <code>-10:00</code> or <code>+1330</code> will work, as will
|
||
# simpler hour-only time zones like <code>-10</code> or
|
||
# <code>+13</code>.
|
||
#
|
||
# Textual time zones listed in ZoneOffset are also supported.
|
||
#
|
||
# If the time zone does not match any of the above, +zone_offset+
|
||
# will check if the local time zone (both with and without
|
||
# potential Daylight Saving \Time changes being in effect) matches
|
||
# +zone+. Specifying a value for +year+ will change the year used
|
||
# to find the local time zone.
|
||
#
|
||
# If +zone_offset+ is unable to determine the offset, nil will be
|
||
# returned.
|
||
def zone_offset(zone, year=self.now.year)
|
||
off = nil
|
||
zone = zone.upcase
|