Method: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Date#cast_value

Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/oid/date.rb

#cast_value(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid/date.rb', line 8

def cast_value(value)
  case value
  when "infinity" then ::Float::INFINITY
  when "-infinity" then -::Float::INFINITY
  when / BC$/
    value = value.sub(/^\d+/) { |year| format("%04d", -year.to_i + 1) }
    super(value.delete_suffix!(" BC"))
  else
    super
  end
end