static public Method

Time.zone_offset(zone, year=Time.now.year)

There's no documentation for this item.

Source Code

# File time.rb, line 69
def zone_offset(zone, year=Time.now.year)
  off = nil
  zone = zone.upcase
  if /\A([+-])(\d\d):?(\d\d)\z/ =~ zone
    off = ($1 == '-' ? -1 : 1) * ($2.to_i * 60 + $3.to_i) * 60
  elsif /\A[+-]\d\d\z/ =~ zone
    off = zone.to_i * 3600
  elsif ZoneOffset.include?(zone)
    off = ZoneOffset[zone] * 3600
  elsif ((t = Time.local(year, 1, 1)).zone.upcase == zone rescue false)
    off = t.utc_offset
  elsif ((t = Time.local(year, 7, 1)).zone.upcase == zone rescue false)
    off = t.utc_offset
  end
  off
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.