aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type
diff options
context:
space:
mode:
authorAnnie-Claude Côté <hello@annie.codes>2018-05-16 15:50:04 -0400
committerAnnie-Claude Côté <hello@annie.codes>2018-05-16 17:01:07 -0400
commit6ff593ef87f0a63e41022cbb3542ff8319e5a630 (patch)
treea79e81651b1450d89d996856724f1723a562d1f2 /activemodel/lib/active_model/type
parent35bf8e90b18954fb1ebf2b4a03a123e04634b064 (diff)
downloadrails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.tar.gz
rails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.tar.bz2
rails-6ff593ef87f0a63e41022cbb3542ff8319e5a630.zip
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".
Diffstat (limited to 'activemodel/lib/active_model/type')
-rw-r--r--activemodel/lib/active_model/type/time.rb2
1 files changed, 2 insertions, 0 deletions
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