Represents a transition from one timezone offset to another at a particular date and time.
The offset this transition changes to (a TimezoneOffset instance).
The offset this transition changes from (a TimezoneOffset instance).
Initializes a new TimezoneTransition.
TimezoneTransition instances should not normally be constructed manually.
# File lib/tzinfo/timezone_transition.rb, line 14 def initialize(offset, previous_offset) @offset = offset @previous_offset = previous_offset @local_end_at = nil @local_start_at = nil end
Returns true if this TimezoneTransition is equal to the given TimezoneTransition. Two TimezoneTransition instances are considered to be equal by == if offset, #previous_offset and at are all equal.
# File lib/tzinfo/timezone_transition.rb, line 90 def ==(tti) tti.kind_of?(TimezoneTransition) && offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at end
A TimeOrDateTime instance representing the UTC time when this transition occurs.
# File lib/tzinfo/timezone_transition.rb, line 23 def at raise_not_implemented('at') end
The UTC time when this transition occurs, returned as a DateTime instance.
# File lib/tzinfo/timezone_transition.rb, line 28 def datetime at.to_datetime end
Returns true if this TimezoneTransition is equal to the given TimezoneTransition. Two TimezoneTransition instances are considered to be equal by eql? if offset, #previous_offset and at are all equal and the type used to define at in both instances is the same.
# File lib/tzinfo/timezone_transition.rb, line 99 def eql?(tti) tti.kind_of?(TimezoneTransition) && offset == tti.offset && previous_offset == tti.previous_offset && at.eql?(tti.at) end
Returns a hash of this TimezoneTransition instance.
# File lib/tzinfo/timezone_transition.rb, line 105 def hash @offset.hash ^ @previous_offset.hash ^ at.hash end
Returns internal object state as a programmer-readable string.
# File lib/tzinfo/timezone_transition.rb, line 110 def inspect "#<#{self.class}: #{at.inspect},#{@offset.inspect}>" end
The local time when this transition causes the previous observance to end, returned as a DateTime instance.
# File lib/tzinfo/timezone_transition.rb, line 52 def local_end local_end_at.to_datetime end
A TimeOrDateTime instance representing the local time when this transition causes the previous observance to end (calculated from at using #previous_offset).
# File lib/tzinfo/timezone_transition.rb, line 40 def local_end_at # Thread-safety: It is possible that the value of @local_end_at may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @local_end_at is only # calculated once. @local_end_at = at.add_with_convert(@previous_offset.utc_total_offset) unless @local_end_at @local_end_at end
The local time when this transition causes the previous observance to end, returned as a Time instance.
# File lib/tzinfo/timezone_transition.rb, line 58 def local_end_time local_end_at.to_time end
The local time when this transition causes the next observance to start, returned as a DateTime instance.
# File lib/tzinfo/timezone_transition.rb, line 76 def local_start local_start_at.to_datetime end
A TimeOrDateTime instance representing the local time when this transition causes the next observance to start (calculated from at using offset).
# File lib/tzinfo/timezone_transition.rb, line 64 def local_start_at # Thread-safety: It is possible that the value of @local_start_at may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @local_start_at is only # calculated once. @local_start_at = at.add_with_convert(@offset.utc_total_offset) unless @local_start_at @local_start_at end
The local time when this transition causes the next observance to start, returned as a Time instance.
# File lib/tzinfo/timezone_transition.rb, line 82 def local_start_time local_start_at.to_time end
The UTC time when this transition occurs, returned as a Time instance.
# File lib/tzinfo/timezone_transition.rb, line 33 def time at.to_time end
# File lib/tzinfo/timezone_transition.rb, line 116 def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end