class TZInfo::DataSources::ConstantOffsetDataTimezoneInfo

Represents a data time zone defined by a constantly observed offset.

Attributes

constant_offset[R]

@return [TimezoneOffset] the offset that is constantly observed.

Public Class Methods

new(identifier, constant_offset) click to toggle source

Initializes a new {ConstantOffsetDataTimezoneInfo}.

The passed in `identifier` instance will be frozen. A reference to the passed in {TimezoneOffset} will be retained.

@param identifier [String] the identifier of the time zone. @param constant_offset [TimezoneOffset] the constantly observed offset. @raise [ArgumentError] if `identifier` or `constant_offset` is `nil`.

Calls superclass method
# File lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb, line 19
def initialize(identifier, constant_offset)
  super(identifier)
  raise ArgumentError, 'constant_offset must be specified' unless constant_offset
  @constant_offset = constant_offset
end

Public Instance Methods

period_for(timestamp) click to toggle source

@param timestamp [Timestamp] ignored. @return [TimezonePeriod] an unbounded {TimezonePeriod} for the time

zone's constantly observed offset.
# File lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb, line 28
def period_for(timestamp)
  constant_period
end
periods_for_local(local_timestamp) click to toggle source

@param local_timestamp [Timestamp] ignored. @return [Array<TimezonePeriod>] an `Array` containing a single unbounded

{TimezonePeriod} for the time zone's constantly observed offset.
# File lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb, line 35
def periods_for_local(local_timestamp)
  [constant_period]
end
transitions_up_to(to_timestamp, from_timestamp = nil) click to toggle source

@param to_timestamp [Timestamp] ignored. @param from_timestamp [Timestamp] ignored. @return [Array] an empty `Array`, since there are no transitions in time

zones that observe a constant offset.
# File lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb, line 43
def transitions_up_to(to_timestamp, from_timestamp = nil)
  []
end

Private Instance Methods

constant_period() click to toggle source

@return [TimezonePeriod] an unbounded {TimezonePeriod} with the constant

offset of this timezone.
# File lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb, line 51
def constant_period
  OffsetTimezonePeriod.new(@constant_offset)
end