A period of time in a timezone where the same offset from UTC applies.

All the methods that take times accept instances of Time, DateTime or integer timestamps.

Methods
#
A
D
E
H
I
L
N
S
T
U
V
Z
Attributes
[R] end_transition

The TimezoneTransitionInfo that defines the end of this TimezonePeriod (may be nil if unbounded).

[R] offset

The TimezoneOffsetInfo for this period.

[R] start_transition

The TimezoneTransitionInfo that defines the start of this TimezonePeriod (may be nil if unbounded).

Class Public methods
new(start_transition, end_transition, offset = nil)

Initializes a new TimezonePeriod.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 44
def initialize(start_transition, end_transition, offset = nil)
  @start_transition = start_transition
  @end_transition = end_transition
  if offset
    raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition
    @offset = offset
  else
    if @start_transition
      @offset = @start_transition.offset
    elsif @end_transition
      @offset = @end_transition.previous_offset
    else
      raise ArgumentError, 'No offset specified and no transitions to determine it from'
    end
  end
  @utc_total_offset_rational = nil
end
Instance Public methods
==(p)

Returns true if this TimezonePeriod is equal to p. This compares the #start_transition, #end_transition and offset using ==.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 170
def ==(p)
  p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
    p.respond_to?(:offset) && start_transition == p.start_transition &&
    end_transition == p.end_transition && offset == p.offset
end
abbreviation()

The identifier of this period, e.g. “GMT” (Greenwich Mean Time) or “BST” (British Summer Time) for “Europe/London”. The returned identifier is a symbol.

Also aliased as: zone_identifier
# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 79
def abbreviation
  @offset.abbreviation
end
dst?()

true if daylight savings is in effect for this period; otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 120
def dst?
  @offset.dst?
end
eql?(p)

Returns true if this TimezonePeriods is equal to p. This compares the #start_transition, #end_transition and offset using eql?

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 178
def eql?(p)
  p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
    p.respond_to?(:offset) && start_transition.eql?(p.start_transition) &&
    end_transition.eql?(p.end_transition) && offset.eql?(p.offset)
end
hash()

Returns a hash of this TimezonePeriod.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 185
def hash
  result = @start_transition.hash ^ @end_transition.hash
  result ^= @offset.hash unless @start_transition || @end_transition
  result
end
inspect()

Returns internal object state as a programmer-readable string.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 192
def inspect
  result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}"
  result << ",#{@offset.inspect}>" unless @start_transition || @end_transition
  result + '>'
end
local_after_start?(local)

true if the given local DateTime is after the start of the period (inclusive); otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 148
def local_after_start?(local)
  !@start_transition || @start_transition.local_start <= local
end
local_before_end?(local)

true if the given local DateTime is before the end of the period (exclusive); otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 154
def local_before_end?(local)
  !@end_transition || @end_transition.local_end > local
end
local_end()

The end time of the period in local time as a DateTime. May be nil if unbounded.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 115
def local_end
  @end_transition ? @end_transition.local_end.to_datetime : nil
end
local_start()

The start time of the period in local time as a DateTime. May be nil if unbounded.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 109
def local_start
  @start_transition ? @start_transition.local_start.to_datetime : nil
end
std_offset()

Offset from the local time where daylight savings is in effect (seconds). E.g.: #utc_offset could be -5 hours. Normally, #std_offset would be 0. During daylight savings, #std_offset would typically become +1 hours.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 72
def std_offset
  @offset.std_offset
end
to_local(utc)

Converts a UTC DateTime to local time based on the offset of this period.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 159
def to_local(utc)
  @offset.to_local(utc)
end
to_utc(local)

Converts a local DateTime to UTC based on the offset of this period.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 164
def to_utc(local)
  @offset.to_utc(local)
end
utc_after_start?(utc)

true if the given UTC DateTime is after the start of the period (inclusive); otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 131
def utc_after_start?(utc)
  !@start_transition || @start_transition.at <= utc
end
utc_before_end?(utc)

true if the given UTC DateTime is before the end of the period (exclusive); otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 137
def utc_before_end?(utc)
  !@end_transition || @end_transition.at > utc
end
utc_end()

The end time of the period in UTC as a DateTime. May be nil if unbounded.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 103
def utc_end
  @end_transition ? @end_transition.at.to_datetime : nil
end
utc_offset()

Base offset of the timezone from UTC (seconds).

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 65
def utc_offset
  @offset.utc_offset
end
utc_start()

The start time of the period in UTC as a DateTime. May be nil if unbounded.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 98
def utc_start
  @start_transition ? @start_transition.at.to_datetime : nil
end
utc_total_offset()

Total offset from UTC (seconds). Equal to #utc_offset + std_offset.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 85
def utc_total_offset
  @offset.utc_total_offset
end
utc_total_offset_rational()

Total offset from UTC (days). Result is a Rational.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 90
def utc_total_offset_rational
  unless @utc_total_offset_rational
    @utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset)
  end
  @utc_total_offset_rational
end
valid_for_local?(local)

true if this period is valid for the given local DateTime; otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 142
def valid_for_local?(local)
  local_after_start?(local) && local_before_end?(local)
end
valid_for_utc?(utc)

true if this period is valid for the given UTC DateTime; otherwise false.

# File activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 125
def valid_for_utc?(utc)
  utc_after_start?(utc) && utc_before_end?(utc)
end
zone_identifier()