Class: ActiveRecord::ConnectionAdapters::PostgreSQL::OID::DateTime

Inherits:
Type::DateTime
  • Object
show all
Defined in:
lib/active_record/connection_adapters/postgresql/oid/date_time.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Type::Internal::Timezone

#default_timezone, #is_utc?

Instance Method Details

#cast_value(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/active_record/connection_adapters/postgresql/oid/date_time.rb', line 6

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