def offsets_up_to(to, from = nil)
      raise ArgumentError, 'to must be specified' unless to

      to_timestamp = Timestamp.for(to)
      from_timestamp = from && Timestamp.for(from)
      transitions = transitions_up_to(to_timestamp, from_timestamp)

      if transitions.empty?
        # No transitions in the range, find the period that covers it.

        if from_timestamp
          # Use the from date as it is inclusive.
          period = period_for(from_timestamp)
        else
          # to is exclusive, so this can't be used with period_for. However, any
          # time earlier than to can be used. Subtract 1 hour.
          period = period_for(to_timestamp.add_and_set_utc_offset(-3600, :utc))
        end

        [period.offset]
      else
        result = Set.new

        first = transitions.first
        result << first.previous_offset unless from_timestamp && first.at == from_timestamp

        transitions.each do |t|
          result << t.offset
        end

        result.to_a
      end
    end
def offsets_up_to(to, from = nil)
      raise ArgumentError, 'to must be specified' unless to

      to_timestamp = Timestamp.for(to)
      from_timestamp = from && Timestamp.for(from)
      transitions = transitions_up_to(to_timestamp, from_timestamp)

      if transitions.empty?
        # No transitions in the range, find the period that covers it.

        if from_timestamp
          # Use the from date as it is inclusive.
          period = period_for(from_timestamp)
        else
          # to is exclusive, so this can't be used with period_for. However, any
          # time earlier than to can be used. Subtract 1 hour.
          period = period_for(to_timestamp.add_and_set_utc_offset(-3600, :utc))
        end

        [period.offset]
      else
        result = Set.new

        first = transitions.first
        result << first.previous_offset unless from_timestamp && first.at == from_timestamp

        transitions.each do |t|
          result << t.offset
        end

        result.to_a
      end
    end
Returns the unique offsets used by the time zone up to a given time (`to`)
 as an `Array` of {TimezoneOffset} instances.

 A from time may also be supplied using the `from` parameter. If from is
 not `nil`, only offsets used from that time onwards will be returned.

 Comparisons with `to` are exclusive. Comparisons with `from` are
 inclusive.

 @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
   latest (exclusive) offset to return.
 @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
   specifying the earliest (inclusive) offset to return.
 @return [Array<TimezoneOffsets>] the offsets that are used earlier than
   `to` and, if specified, at or later than `from`. Offsets may be returned
   in any order.
 @raise [ArgumentError] if `from` is specified and `to` is not greater than
   `from`.
 @raise [ArgumentError] is raised if `to` is `nil`.
 @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
   unspecified offset.