123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::TimezoneTransition

Relationships & Source Files
Inherits: Object
Defined in: lib/tzinfo/timezone_transition.rb

Overview

Represents a transition from one observed UTC offset (TimezoneOffset to another for a time zone.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(offset, previous_offset, timestamp_value) ⇒ TimezoneTransition

Initializes a new TimezoneTransition.

TimezoneTransition instances should not normally be constructed manually.

Parameters:

  • offset (TimezoneOffset)

    the offset the transition changes to.

  • previous_offset (TimezoneOffset)

    the offset the transition changes from.

  • timestamp_value (Integer)

    when the transition occurs as a 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).

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 34

def initialize(offset, previous_offset, timestamp_value)
  @offset = offset
  @previous_offset = previous_offset
  @timestamp_value = timestamp_value
end

Instance Attribute Details

#offsetTimezoneOffset (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 9

attr_reader :offset

#previous_offsetTimezoneOffset (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 12

attr_reader :previous_offset

#timestamp_valueInteger (readonly)

When this 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). Equivalent to the result of calling the value method on the Timestamp returned by #at.

Returns:

  • (Integer)

    when this transition occurs as a number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds.

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 21

attr_reader :timestamp_value

Instance Method Details

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

Determines if this TimezoneTransition is equal to another instance.

Parameters:

  • tti (Object)

    the instance to test for equality.

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 86

def ==(tti)
  tti.kind_of?(TimezoneTransition) &&
    offset == tti.offset && previous_offset == tti.previous_offset && timestamp_value == tti.timestamp_value
end

#atTimestamp

Returns a Timestamp instance representing the UTC time when this transition occurs.

To obtain the result as a Time or DateTime, call either to_time or to_datetime on the Timestamp instance that is returned.

Returns:

  • (Timestamp)

    the UTC time when this transition occurs.

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 48

def at
  Timestamp.utc(@timestamp_value)
end

#eql?(tti)

Alias for #==.

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 90

alias eql? ==

#hashInteger

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 94

def hash
  [@offset, @previous_offset, @timestamp_value].hash
end

#local_end_atTimestampWithOffset

Returns a TimestampWithOffset instance representing the local time when this transition causes the previous observance to end (calculated from #at using #previous_offset).

To obtain the result as a Time or DateTime, call either to_time or to_datetime on the TimestampWithOffset instance that is returned.

Returns:

  • (TimestampWithOffset)

    the local time when this transition causes the previous observance to end.

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 62

def local_end_at
  TimestampWithOffset.new(@timestamp_value, 0, @previous_offset.observed_utc_offset).set_timezone_offset(@previous_offset)
end

#local_start_atTimestampWithOffset

Returns a TimestampWithOffset instance representing the local time when this transition causes the next observance to start (calculated from #at using #offset).

To obtain the result as a Time or DateTime, call either to_time or to_datetime on the TimestampWithOffset instance that is returned.

Returns:

  • (TimestampWithOffset)

    the local time when this transition causes the next observance to start.

[ GitHub ]

  
# File 'lib/tzinfo/timezone_transition.rb', line 76

def local_start_at
  TimestampWithOffset.new(@timestamp_value, 0, @offset.observed_utc_offset).set_timezone_offset(@offset)
end