123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::Format1::TimezoneDefiner Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TZInfo::Format2::TimezoneDefiner
Defined in: lib/tzinfo/format1/timezone_definer.rb

Overview

Instances of TimezoneDefiner are yielded to TZInfo::Data format 1 modules by TimezoneDefinition to allow the offsets and transitions of the time zone to be specified.

Class Method Summary

::TZInfo::Format2::TimezoneDefiner - Inherited

.new

Initializes a new TimezoneDefiner.

Instance Attribute Summary

Instance Method Summary

::TZInfo::Format2::TimezoneDefiner - Inherited

#first_offset

Returns the first offset to be defined or nil if no offsets have been defined.

#offset

Defines an offset.

#subsequent_rules

Defines the rules that will be used for handling instants after the last transition.

#transition

Defines a transition to a given offset.

Instance Method Details

#offset(id, utc_offset, std_offset, abbreviation)

Defines an offset.

Parameters:

  • id (Symbol)

    an arbitrary value used identify the offset in subsequent calls to transition. It must be unique.

  • utc_offset (Integer)

    the base offset from UTC of the zone in seconds. This does not include daylight savings time.

  • std_offset (Integer)

    the daylight savings offset from the base offset in seconds. Typically either 0 or 3600.

  • abbreviation (Symbol)

    an abbreviation for the offset, for example, :EST or :EDT.

Raises:

  • (ArgumentError)

    if another offset has already been defined with the given id.

[ GitHub ]

  
# File 'lib/tzinfo/format1/timezone_definer.rb', line 26

def offset(id, utc_offset, std_offset, abbreviation)
  super(id, utc_offset, std_offset, abbreviation.to_s)
end

#transition(year, month, offset_id, timestamp_value, datetime_numerator = nil, datetime_denominator = nil)

Defines a transition to a given offset.

Transitions must be defined in increasing time order.

Parameters:

  • year (Integer)

    the UTC year in which the transition occurs. Used in earlier versions of ::TZInfo, but now ignored.

  • month (Integer)

    the UTC month in which the transition occurs. Used in earlier versions of ::TZInfo, but now ignored.

  • offset_id (Symbol)

    references the id of a previously defined offset (see #offset).

  • timestamp_value (Integer)

    the time the transition occurs as an Integer number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds (i.e. each day is treated as if it were 86,400 seconds long).

  • datetime_numerator (Integer) (defaults to: nil)

    the time of the transition as the numerator of the Rational returned by DateTime#ajd. Used in earlier versions of ::TZInfo, but now ignored.

  • datetime_denominator (Integer) (defaults to: nil)

    the time of the transition as the denominator of the Rational returned by DateTime#ajd. Used in earlier versions of ::TZInfo, but now ignored.

Raises:

  • (ArgumentError)

    if offset_id does not reference a defined offset.

  • (ArgumentError)

    if timestamp_value is not greater than the timestamp_value of the previously defined transition.

  • (ArgumentError)

    if datetime_numerator is specified, but datetime_denominator is not. In older versions of ::TZInfo, it was possible to define a transition with the DateTime numerator as the 4th parameter and the denominator as the 5th parameter. This style of definition is not used in released versions of TZInfo::Data.

[ GitHub ]

  
# File 'lib/tzinfo/format1/timezone_definer.rb', line 58

def transition(year, month, offset_id, timestamp_value, datetime_numerator = nil, datetime_denominator = nil)
  raise ArgumentError, 'DateTime-only transitions are not supported' if datetime_numerator && !datetime_denominator
  super(offset_id, timestamp_value)
end