123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::TransitionsTimezonePeriod

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TZInfo::TimezonePeriod
Defined in: lib/tzinfo/transitions_timezone_period.rb

Overview

Represents a period of time in a time zone where the same offset from UTC applies. The period of time is bounded at at least one end, either having a start transition, end transition or both start and end transitions.

Class Method Summary

TimezonePeriod - Inherited

.new

Initializes a TimezonePeriod.

Instance Attribute Summary

TimezonePeriod - Inherited

#dst?

Determines if daylight savings is in effect (i.e.

#offset

Instance Method Summary

TimezonePeriod - Inherited

#abbr
#abbreviation

The abbreviation that identifies this offset.

#base_utc_offset

Returns the base offset from UTC in seconds (observed_utc_offset - std_offset).

#end_transition,
#ends_at

Returns the UTC end time of the period or nil if the end of the period is unbounded.

#local_ends_at

Returns the local end time of the period or nil if the end of the period is unbounded.

#local_starts_at

Returns the local start time of the period or nil if the start of the period is unbounded.

#observed_utc_offset

Returns the observed offset from UTC in seconds (base_utc_offset + std_offset).

#start_transition,
#starts_at

Returns the UTC start time of the period or nil if the start of the period is unbounded.

#std_offset

Returns the offset from the time zone's standard time in seconds (observed_utc_offset - base_utc_offset).

#utc_offset
#utc_total_offset
#zone_identifier
#raise_not_implemented

Raises a NotImplementedError to indicate that subclasses should override a method.

#timestamp, #timestamp_with_offset

Constructor Details

.new(start_transition, end_transition) ⇒ TransitionsTimezonePeriod

Initializes a TransitionsTimezonePeriod.

At least one of start_transition and end_transition must be specified.

Parameters:

  • start_transition (TimezoneTransition)

    the transition that defines the start of the period, or nil if the start is unbounded.

  • end_transition (TimezoneTransition)

    the transition that defines the end of the period, or nil if the end is unbounded.

Raises:

  • (ArgumentError)

    if both start_transition and end_transition are nil.

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 27

def initialize(start_transition, end_transition)
  if start_transition
    super(start_transition.offset)
  elsif end_transition
    super(end_transition.previous_offset)
  else
    raise ArgumentError, 'At least one of start_transition and end_transition must be specified'
  end

  @start_transition = start_transition
  @end_transition = end_transition
end

Instance Attribute Details

#end_transitionTimezoneTransition (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 15

attr_reader :end_transition

#start_transitionTimezoneTransition (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 11

attr_reader :start_transition

Instance Method Details

#==(p) ⇒ Boolean Also known as: #eql?

Determines if this TransitionsTimezonePeriod is equal to another instance.

Parameters:

  • p (Object)

    the instance to test for equality.

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 47

def ==(p)
  p.kind_of?(TransitionsTimezonePeriod) && start_transition == p.start_transition && end_transition == p.end_transition
end

#eql?(p)

Alias for #==.

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 50

alias eql? ==

#hashInteger

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 53

def hash
  [@start_transition, @end_transition].hash
end

#inspectString

Returns:

  • (String)

    the internal object state as a programmer-readable String.

[ GitHub ]

  
# File 'lib/tzinfo/transitions_timezone_period.rb', line 59

def inspect
  "#<#{self.class}: @start_transition=#{@start_transition.inspect}, @end_transition=#{@end_transition.inspect}>"
end