Sha256: 56ab67a8c1793737b376c1fb5dee9004602263a23db4612f762588171f867c40

Contents?: true

Size: 820 Bytes

Versions: 37

Compression:

Stored size: 820 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 PostgreSQL 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

37 entries across 37 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activerecord-7.1.3.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.0.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.2.2.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.5.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.0 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.2.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.5 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.0.rc2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.2.1.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.4.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.0.rc1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.2.1.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.1.4.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-8.0.0.beta1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
omg-activerecord-8.0.0.alpha9 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
omg-activerecord-8.0.0.alpha8 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
omg-activerecord-8.0.0.alpha7 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
omg-activerecord-8.0.0.alpha4 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
omg-activerecord-8.0.0.alpha3 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb