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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---