Method: Sequel::SequelMethods#convert_output_timestamp

Defined in:
lib/sequel/timezones.rb

#convert_output_timestamp(v, output_timezone) ⇒ Object

Converts the object to the given output_timezone.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/sequel/timezones.rb', line 55

def convert_output_timestamp(v, output_timezone)
  if output_timezone
    if v.is_a?(DateTime)
      case output_timezone
      when :utc
        v.new_offset(0)
      when :local
        v.new_offset(local_offset_for_datetime(v))
      else
        convert_output_datetime_other(v, output_timezone)
      end
    else
      case output_timezone
      when :utc
        v.getutc
      when :local
        v.getlocal
      else
        convert_output_time_other(v, output_timezone)
      end
    end
  else
    v
  end
end