module Sequel::NamedTimezones

Attributes

tzinfo_disambiguator[RW]

Handles TZInfo::AmbiguousTime exceptions automatically by providing a proc called with both the datetime value being converted as well as the array of TZInfo::TimezonePeriod results. Example:

Sequel.tzinfo_disambiguator = proc{|datetime, periods| periods.first}

Private Instance Methods

convert_input_time_other(v, input_timezone) click to toggle source

Convert the given input Time (which must be in UTC) to the given input timezone, which should be a TZInfo::Timezone instance.

   # File lib/sequel/extensions/named_timezones.rb
73 def convert_input_time_other(v, input_timezone)
74   Time.new(v.year, v.mon, v.day, v.hour, v.min, (v.sec + Rational(v.nsec, 1000000000)), input_timezone)
75 rescue TZInfo::AmbiguousTime
76   raise unless disamb = tzinfo_disambiguator_for(v)
77   period = input_timezone.period_for_local(v, &disamb)
78   offset = period.utc_total_offset
79   Time.at(v.to_i - offset, :in => input_timezone)
80 end
convert_output_time_other(v, output_timezone) click to toggle source

Convert the given input Time to the given output timezone, which should be a TZInfo::Timezone instance.

   # File lib/sequel/extensions/named_timezones.rb
84 def convert_output_time_other(v, output_timezone)
85   Time.at(v.to_i, :in => output_timezone)
86 end