class TZInfo::Timezone
def local_to_utc(local_time, dst = Timezone.default_dst)
-
(AmbiguousTime)- if `local_time` was ambiguous for the time zone and -
(PeriodNotFound)- if `local_time` is not valid for the time zone -
(ArgumentError)- if `local_time` is `nil`.
Returns:
-
(Object)- the UTC equivalent of `local_time` as a `Time`,
Other tags:
- Yieldreturn: - to resolve the ambiguity: a chosen {TimezonePeriod}
Other tags:
- Yieldparam: periods - an `Array` containing all
Other tags:
- Yield: - if the `dst` parameter did not resolve an ambiguity, an
Parameters:
-
dst(Boolean) -- whether to resolve ambiguous local times by always -
local_time(Object) -- a `Time`, `DateTime` or {Timestamp}.
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