Sha256: 8a2b6458442ecb22ddd5a0b901531194df47c09e5899dd371c414610dc2ce8b0

Contents?: true

Size: 608 Bytes

Versions: 69

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module OID # :nodoc:
        class Date < Type::Date # :nodoc:
          def cast_value(value)
            case value
            when "infinity" then ::Float::INFINITY
            when "-infinity" then -::Float::INFINITY
            when / BC$/
              astronomical_year = format("%04d", -value[/^\d+/].to_i + 1)
              super(value.sub(/ BC$/, "").sub(/^\d+/, astronomical_year))
            else
              super
            end
          end
        end
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 6 rubygems

Version Path
activerecord-6.0.6.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.6 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.5.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.8.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.8 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.5 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.8 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.7.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.7 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.7 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.6.3 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.6 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.6.2 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.6.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.5 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.4 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.3 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.2 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-6.0.4 lib/active_record/connection_adapters/postgresql/oid/date.rb