From d3b126729bee8898c270c3a32416628e65ec7a95 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Wed, 21 May 2008 11:01:41 +1000 Subject: [PATCH] modified conversion for rails <= 2.0.2 to be faster usign schema conversion methods --- lib/validates_timeliness/attribute_methods.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/validates_timeliness/attribute_methods.rb b/lib/validates_timeliness/attribute_methods.rb index e17b9ce..9a7e6b1 100644 --- a/lib/validates_timeliness/attribute_methods.rb +++ b/lib/validates_timeliness/attribute_methods.rb @@ -91,9 +91,11 @@ module ValidatesTimeliness return cached if cached && !reload time = read_attribute_before_type_cast('#{attr_name}') unless time.acts_like?(:time) - # check invalid date - time.to_date rescue time = nil - time = time.to_time if time + klass = ActiveRecord::ConnectionAdapters::Column + # check for invalid date + time = nil unless klass.string_to_date(time) + # convert to time if still valid + time = klass.string_to_time(time) if time end @attributes_cache['#{attr_name}'] = time end