Этот конкретный код (тот, который выполняет преобразование) может быть отслежен с lib/active_record/connection_adapters/abstract/schema_definitions.rb
, строка № 67 и далее, т.е. метод type_cast
.
Эти два метода используются для генерации даты из строки:
def fast_string_to_date(string)
if string =~ Format::ISO_DATE
new_date $1.to_i, $2.to_i, $3.to_i
end
end
# Doesn't handle time zones.
def fast_string_to_time(string)
if string =~ Format::ISO_DATETIME
microsec = ($7.to_f * 1_000_000).to_i
new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
end
end
# Note that ISO_DATE is:
ISO_DATE = /\A(\d{4})-(\d\d)-(\d\d)\z/