Sha256: 5c22c40f7adcc14a119bd192ec29e6f4fe747f2e857e98f4c4c1140e1e12d1ef

Contents?: true

Size: 791 Bytes

Versions: 20

Compression:

Stored size: 791 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)

            # 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

20 entries across 18 versions & 3 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.4.3 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.4.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.4.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.4 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.3.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.3 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.2.4 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.2.3 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.2.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.2.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.2 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb
activerecord-7.0.1 lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb