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.0.beta1 lib/active_record/connection_adapters/postgresql/oid/date.rb
nullifyable-0.1.0 vendor/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.2 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.2.rc1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.1.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.1.rc1 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.0 lib/active_record/connection_adapters/postgresql/oid/date.rb
activerecord-5.2.0.rc2 lib/active_record/connection_adapters/postgresql/oid/date.rb