From 6ff593ef87f0a63e41022cbb3542ff8319e5a630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Annie-Claude=20C=C3=B4t=C3=A9?= Date: Wed, 16 May 2018 15:50:04 -0400 Subject: Fix user_input_in_time_zone to coerce non valid string into nil Before it was coercing an invalid string into "2000-01-01 00:00:00". --- activemodel/lib/active_model/type/time.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activemodel/lib/active_model/type') diff --git a/activemodel/lib/active_model/type/time.rb b/activemodel/lib/active_model/type/time.rb index c094ee0013..b3056b1333 100644 --- a/activemodel/lib/active_model/type/time.rb +++ b/activemodel/lib/active_model/type/time.rb @@ -18,6 +18,8 @@ module ActiveModel case value when ::String value = "2000-01-01 #{value}" + time_hash = ::Date._parse(value) + return if time_hash[:hour].nil? when ::Time value = value.change(year: 2000, day: 1, month: 1) end -- cgit v1.2.3