Sha256: ba48cf6323a33970163177ed3fefcbb7bf11290b266b8fcd3c3b5d916122da8c

Contents?: true

Size: 781 Bytes

Versions: 32

Compression:

Stored size: 781 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module CipherStashPG
      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 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
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.7.4 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.7.3 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.7.2 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.7.1 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.7.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.6.1 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.6.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.5.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.4.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.3.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.2.0 lib/active_record/connection_adapters/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.1.0 lib/active_record/connection_adapters/cipherstash_pg/oid/timestamp_with_time_zone.rb