Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::TimestampWithTimeZone

Inherits:
DateTime show all
Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ActiveModel::Type::Value

#limit, #precision, #scale

Instance Method Summary collapse

Methods inherited from DateTime

#type_cast_for_schema

Methods included from Type::Internal::Timezone

#default_timezone, #initialize, #is_utc?

Methods included from ActiveModel::Type::Helpers::TimeValue

#apply_seconds_precision, #serialize_cast_value, #type_cast_for_schema, #user_input_in_time_zone

Methods included from ActiveModel::Type::Helpers::Timezone

#default_timezone, #is_utc?

Methods inherited from ActiveModel::Type::Value

#==, #as_json, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #immutable_value, #initialize, #map, #serializable?, #serialize, #type_cast_for_schema, #value_constructed_by_mass_assignment?

Instance Method Details

#cast_value(value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb', line 12

def cast_value(value)
  return if value.blank?

  time = super
  return time unless time.acts_like?(:time)

  # While in UTC mode, the PG gem may not return times back in "UTC" even if they were provided to Postgres in UTC.
  # We prefer times always in UTC, so here we convert back.
  if is_utc?
    time.getutc
  else
    time.getlocal
  end
end

#typeObject



8
9
10
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb', line 8

def type
  real_type_unless_aliased(:timestamptz)
end