Hi,
Ive been having problems with dates prior to 1070 in rails and have
found the following fix on the rails wiki:
ruby does do dates before 1970, but with a different class: DateTime.
But ActiveRecord’s string_to_date conversion only uses the Time class.
Here’s a patch for ActiveRecord::ConnectionAdapters::Column which will
force ActiveRecord to fallback to DateTime if Time is not sufficient.
require ‘date’
It’s necessary to do this, because Time doesn’t
support dates before 1970…
class ActiveRecord::ConnectionAdapters::Column
def self.string_to_time(string)
return string unless string.is_a?(String)
time_array = ParseDate.parsedate(string)[0…5]
begin
Time.send(Base.default_timezone, *time_array)
rescue
DateTime.new(*time_array) rescue nil
end
end
end
This is all well and good but where exactly do I put this fix in my
project to fix active record?
Many thanks,
Chris