class TZInfo::TZDataFormat

:nodoc:
@private
substitution (%s) format or a fixed string.
A tz data Zone format string. Either alternate standard/daylight-savings,

def expand(utc_offset, std_offset, rule_string)

offset and rule string.
Expands given the base offset to UTC, the current daylight savings
def expand(utc_offset, std_offset, rule_string)
  if @type == :alternate
    if std_offset == 0
      @standard_abbrev
    else
      @daylight_abbrev
    end
  elsif @type == :subst
    @abbrev.gsub(/%([sz])/) do
      $1 == 's' ? rule_string : format_offset(utc_offset + std_offset)
    end
  else
    @abbrev
  end        
end

def fixed?

Is a fixed format string.
def fixed?
  @type == :fixed
end

def format_offset(offset)

Formats an offset according to the rules for %z.
def format_offset(offset)
  if offset < 0
    offset = -offset
    sign = '-'
  else
    sign = '+'
  end
  offset, seconds = offset.divmod(60)
  offset, minutes = offset.divmod(60)
  if offset > 99
    # unsupported
    '%z'
  else
    result = "#{sign}#{offset.to_s.rjust(2, '0')}"
    if minutes != 0 || seconds != 0
      result << minutes.to_s.rjust(2, '0')
      if seconds != 0
        result << seconds.to_s.rjust(2, '0')
      end
    end
    result
  end
end

def initialize(spec)

Other tags:
    Private: -
def initialize(spec)
  if spec =~ /\A([^\/]*)\/(.*)\z/
    @type = :alternate
    @standard_abbrev = $1
    @daylight_abbrev = $2
  elsif spec =~ /%[sz]/
    @type = :subst
    @abbrev = spec
  else
    @type = :fixed
    @abbrev = spec
  end
end

def subst?

True if the format requires substitutions (%s or %z).
def subst?
  @type == :subst
end