From 67183eb69f00a9811cea4bfd7d0b69cc0080d6bd Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Tue, 1 Jul 2008 11:33:20 +1000 Subject: [PATCH] changed strict_time_type_cast to use validation parse method to unify and allow pluggable parsers --- lib/validates_timeliness/attribute_methods.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/validates_timeliness/attribute_methods.rb b/lib/validates_timeliness/attribute_methods.rb index a095c8b..e4ab4b3 100644 --- a/lib/validates_timeliness/attribute_methods.rb +++ b/lib/validates_timeliness/attribute_methods.rb @@ -31,13 +31,12 @@ module ValidatesTimeliness # Does strict time type cast checking for Rails 2.1 timezone handling def strict_time_type_cast(time) unless time.acts_like?(:time) - time.to_date rescue time = nil - time = time && defined?(ActiveSupport::TimeWithZone) ? Time.zone.parse(time) : time.to_time rescue nil + time = self.class.timeliness_date_time_parse(time) end time_in_time_zone(time) end - # Handles timezone shift for Rails 2.1 or just returns time for old versions + # Handles timezone shift if Rails 2.1 def time_in_time_zone(time) time.respond_to?(:in_time_zone) ? time.in_time_zone : time end