def local_to_utc(local_time, dst = Timezone.default_dst)
      raise ArgumentError, 'local_time must be specified' unless local_time

      Timestamp.for(local_time, :ignore) do |ts|
        period = if block_given?
          period_for_local(ts, dst) {|periods| yield periods }
        else
          period_for_local(ts, dst)
        end

        ts.add_and_set_utc_offset(-period.observed_utc_offset, :utc)
      end
    end
def local_to_utc(local_time, dst = Timezone.default_dst)
      raise ArgumentError, 'local_time must be specified' unless local_time

      Timestamp.for(local_time, :ignore) do |ts|
        period = if block_given?
          period_for_local(ts, dst) {|periods| yield periods }
        else
          period_for_local(ts, dst)
        end

        ts.add_and_set_utc_offset(-period.observed_utc_offset, :utc)
      end
    end
Converts a local time for the time zone to UTC.

 The result will either be a `Time`, `DateTime` or {Timestamp} according to
 the type of the `local_time` parameter.

 The UTC offset of the `local_time` parameter is ignored (it is treated as
 a time in the time zone represented by `self`).

 _Warning:_ There are local times that have no equivalent UTC times (for
 example, during the transition from standard time to daylight savings
 time). There are also local times that have more than one UTC equivalent
 (for example, during the transition from daylight savings time to standard
 time).

 In the first case (no equivalent UTC time), a {PeriodNotFound} exception
 will be raised.

 In the second case (more than one equivalent UTC time), an {AmbiguousTime}
 exception will be raised unless the optional `dst` parameter or block
 handles the ambiguity.

 If the ambiguity is due to a transition from daylight savings time to
 standard time, the `dst` parameter can be used to select whether the
 daylight savings time or local time is used. For example, the following
 code would raise an {AmbiguousTime} exception:

     tz = TZInfo::Timezone.get('America/New_York')
     tz.period_for_local(Time.new(2004,10,31,1,30,0))

 Specifying `dst = true` would select the daylight savings period from
 April to October 2004. Specifying `dst = false` would return the
 standard time period from October 2004 to April 2005.

 The `dst` parameter will not be able to resolve an ambiguity resulting
 from the clocks being set back without changing from daylight savings time
 to standard time. In this case, if a block is specified, it will be called
 to resolve the ambiguity. The block must take a single parameter - an
 `Array` of {TimezonePeriod}s that need to be resolved. The block can
 select and return a single {TimezonePeriod} or return `nil` or an empty
 `Array` to cause an {AmbiguousTime} exception to be raised.

 The default value of the `dst` parameter can be specified using
 {Timezone.default_dst=}.

 @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
 @param dst [Boolean] whether to resolve ambiguous local times by always
   selecting the period observing daylight savings time (`true`), always
   selecting the period observing standard time (`false`), or leaving the
   ambiguity unresolved (`nil`).
 @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
   optional block is yielded to.
 @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
   the {TimezonePeriod}s that still match `local_time` after applying the
   `dst` parameter.
 @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
   or an `Array` containing a chosen {TimezonePeriod}; to leave the
   ambiguity unresolved: an empty `Array`, an `Array` containing more than
   one {TimezonePeriod}, or `nil`.
 @return [Object] the UTC equivalent of `local_time` as a `Time`,
   `DateTime` or {Timestamp}.
 @raise [ArgumentError] if `local_time` is `nil`.
 @raise [PeriodNotFound] if `local_time` is not valid for the time zone
   (there is no equivalent UTC time).
 @raise [AmbiguousTime] if `local_time` was ambiguous for the time zone and
   the `dst` parameter or block did not resolve the ambiguity.