Flowdock
method

zone_to_diff

Importance_0
Ruby latest stable (v1_9_3_392) - 0 notes - Class: Date

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v1_8_7_330) is shown here.

zone_to_diff(zone) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/date/format.rb, line 1120
  def self.zone_to_diff(zone) # :nodoc:
    zone = zone.downcase
    if zone.sub!(/\s+(standard|daylight)\s+time\z/, '')
      dst = $1 == 'daylight'
    else
      dst = zone.sub!(/\s+dst\z/, '')
    end
    if Format::ZONES.include?(zone)
      offset = Format::ZONES[zone]
      offset += 3600 if dst
    elsif zone.sub!(/\A(?:gmt|utc?)?([-+])/, '')
      sign = $1
      if zone.include?(':')
        hour, min, sec, = zone.split(':')
      elsif zone.include?(',') || zone.include?('.')
        hour, fr, = zone.split(/[,.]/)
        min = Rational(fr.to_i, 10**fr.size) * 60
      else
        case zone.size
        when 3
          hour = zone[0,1]
          min = zone[1,2]
        else
          hour = zone[0,2]
          min = zone[2,2]
          sec = zone[4,2]
        end
      end
      offset = hour.to_i * 3600 + min.to_i * 60 + sec.to_i
      offset *= -1 if sign == '-'
    end
    offset
  end
Register or log in to add new notes.