From 8f387995054d9ce79522da8ef65fba28c6ea0785 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 20 May 2014 14:07:58 -0700 Subject: Inline typecasting helpers from Column to the appropriate types --- .../lib/active_record/connection_adapters/type/time.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/type/time.rb') diff --git a/activerecord/lib/active_record/connection_adapters/type/time.rb b/activerecord/lib/active_record/connection_adapters/type/time.rb index b621e8f39c..4dd201e3fe 100644 --- a/activerecord/lib/active_record/connection_adapters/type/time.rb +++ b/activerecord/lib/active_record/connection_adapters/type/time.rb @@ -11,7 +11,16 @@ module ActiveRecord private def cast_value(value) - Column.string_to_dummy_time(value) + return value unless value.is_a?(::String) + return if value.empty? + + dummy_time_value = "2000-01-01 #{value}" + + fast_string_to_time(dummy_time_value) || begin + time_hash = ::Date._parse(dummy_time_value) + return if time_hash[:hour].nil? + new_time(*time_hash.values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction)) + end end end end -- cgit v1.2.3