Class: ActiveRecord::ConnectionAdapters::Redshift::OID::DateTime

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

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Infinity

#infinity

Instance Method Details

#cast_value(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_record/connection_adapters/redshift/oid/date_time.rb', line 8

def cast_value(value)
  if value.is_a?(::String)
    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
  else
    value
  end
end