Sha256: 4e48ae4cf7dd3cf0a4b607ba5513d5f58d46d8a973f169fba1cef353c57282fb

Contents?: true

Size: 818 Bytes

Versions: 14

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module OID # :nodoc:
        class TimestampWithTimeZone < DateTime # :nodoc:
          def type
            real_type_unless_aliased(:timestamptz)
          end

          def cast_value(value)
            return if value.blank?

            time = super
            return time if time.is_a?(ActiveSupport::TimeWithZone) || !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
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
activerecord-7.0.8.6 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.8.5 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.8.4 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.8.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.0 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.0.rc2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.0.rc1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.0.beta1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.8 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.7.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.7.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.7 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.6 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb