Class: TZInfo::DataSources::ConstantOffsetDataTimezoneInfo

Inherits:
DataTimezoneInfo show all
Defined in:
lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from TimezoneInfo

#identifier

Instance Method Summary collapse

Methods inherited from DataTimezoneInfo

#create_timezone

Methods inherited from TimezoneInfo

#create_timezone, #inspect

Constructor Details

#initialize(identifier, constant_offset) ⇒ ConstantOffsetDataTimezoneInfo

Initializes a new TZInfo::DataSources::ConstantOffsetDataTimezoneInfo.

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

Parameters:

  • identifier (String)

    the identifier of the time zone.

  • constant_offset (TimezoneOffset)

    the constantly observed offset.

Raises:

  • (ArgumentError)

    if identifier or constant_offset is nil.



19
20
21
22
23
# 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

Instance Attribute Details

#constant_offsetTimezoneOffset (readonly)

Returns the offset that is constantly observed.

Returns:



9
10
11
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 9

def constant_offset
  @constant_offset
end

Instance Method Details

#period_for(timestamp) ⇒ TimezonePeriod

Returns an unbounded TimezonePeriod for the time zone's constantly observed offset.

Parameters:

Returns:



28
29
30
# 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) ⇒ Array<TimezonePeriod>

Returns an Array containing a single unbounded TimezonePeriod for the time zone's constantly observed offset.

Parameters:

Returns:



35
36
37
# 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) ⇒ Array

Returns an empty Array, since there are no transitions in time zones that observe a constant offset.

Parameters:

  • to_timestamp (Timestamp)

    ignored.

  • from_timestamp (Timestamp) (defaults to: nil)

    ignored.

Returns:

  • (Array)

    an empty Array, since there are no transitions in time zones that observe a constant offset.



43
44
45
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 43

def transitions_up_to(to_timestamp, from_timestamp = nil)
  []
end