From 5cd3bbbb832b58d2a0092f527d83312df4271de7 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 14 Jun 2014 08:06:51 -0600 Subject: Time columns should support time zone aware attributes The types that are affected by `time_zone_aware_attributes` (which is on by default) have been made configurable, in case this is a breaking change for existing applications. --- activerecord/lib/active_record/type/time.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/lib/active_record/type/time.rb') diff --git a/activerecord/lib/active_record/type/time.rb b/activerecord/lib/active_record/type/time.rb index 41f7d97f0c..cab1c7bf1e 100644 --- a/activerecord/lib/active_record/type/time.rb +++ b/activerecord/lib/active_record/type/time.rb @@ -7,6 +7,19 @@ module ActiveRecord :time end + def user_input_in_time_zone(value) + return unless value.present? + + case value + when ::String + value = "2000-01-01 #{value}" + when ::Time + value = value.change(year: 2000, day: 1, month: 1) + end + + super(value) + end + private def cast_value(value) -- cgit v1.2.3