Sha256: 7a46a683c28b7c1cd7a92444057d4f45a983da7eb65fb868040325396de8f8cd

Contents?: true

Size: 821 Bytes

Versions: 4

Compression:

Stored size: 821 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 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

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.8.5 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.8.4 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.8.3 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/timestamp_with_time_zone.rb
activerecord-cipherstash-pg-adapter-0.8.2 lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/timestamp_with_time_zone.rb