class TZInfo::Format2::TimezoneDefiner

:nodoc:
@private
to be specified.
{TimezoneDefinition} to allow the offsets and transitions of the time zone
Instances of {TimezoneDefiner} are yielded to TZInfo::Data modules by

def first_offset

Returns:
  • (TimezoneOffset) - the first offset to be defined or `nil` if no
def first_offset
  first = @offsets.first
  first && first.last
end

def initialize(string_deduper)

Parameters:
  • string_deduper (StringDeduper) -- a {StringDeduper} instance to use
def initialize(string_deduper)
  @string_deduper = string_deduper
  @offsets = {}
  @transitions = []
end

def offset(id, base_utc_offset, std_offset, abbreviation)

Raises:
  • (ArgumentError) - if another offset has already been defined with

Parameters:
  • abbreviation (String) -- an abbreviation for the offset, for
  • std_offset (Integer) -- the daylight savings offset from the base
  • base_utc_offset (Integer) -- the base offset from UTC of the zone in
  • id (Symbol) -- an arbitrary value used identify the offset in
def offset(id, base_utc_offset, std_offset, abbreviation)
  raise ArgumentError, 'An offset has already been defined with the given id' if @offsets.has_key?(id)
  # Dedupe non-frozen literals from format 1 on all Ruby versions and
  # format 2 on Ruby < 2.3 (without frozen_string_literal support).
  abbreviation = @string_deduper.dedupe(abbreviation)
  offset = TimezoneOffset.new(base_utc_offset, std_offset, abbreviation)
  @offsets[id] = offset
  @previous_offset ||= offset
end

def subsequent_rules(*args)

and the rules will be included in format 2 releases of TZInfo::Data.
Support for subsequent rules will be added in a future version of TZInfo

that accepts and ignores any arguments passed.
This method is currently just a placeholder for forward compatibility

transition.
Defines the rules that will be used for handling instants after the last
def subsequent_rules(*args)
end

def transition(offset_id, timestamp_value)

Raises:
  • (ArgumentError) - if `timestamp_value` is not greater than the
  • (ArgumentError) - if `offset_id` does not reference a defined

Parameters:
  • timestamp_value (Integer) -- the time the transition occurs as a
  • offset_id (Symbol) -- references the id of a previously defined
def transition(offset_id, timestamp_value)
  offset = @offsets[offset_id]
  raise ArgumentError, 'offset_id has not been defined' unless offset
  raise ArgumentError, 'timestamp is not greater than the timestamp of the previously defined transition' if !@transitions.empty? && @transitions.last.timestamp_value >= timestamp_value
  @transitions << TimezoneTransition.new(offset, @previous_offset, timestamp_value)
  @previous_offset = offset
end