diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-01-15 08:08:30 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-01-15 08:08:30 -0700 |
commit | b814d8c98fe6b21e9097b1e69851275c148e555a (patch) | |
tree | c85d3c4c19f19118e3b7eab8222bd4daab0397df /activerecord/lib/active_record/type/time.rb | |
parent | 3f96b6973b82ad17e443dd1d21be05996fb6fbf0 (diff) | |
parent | 5cd3bbbb832b58d2a0092f527d83312df4271de7 (diff) | |
download | rails-b814d8c98fe6b21e9097b1e69851275c148e555a.tar.gz rails-b814d8c98fe6b21e9097b1e69851275c148e555a.tar.bz2 rails-b814d8c98fe6b21e9097b1e69851275c148e555a.zip |
Merge pull request #15726 from sgrif/sg-time-zone-aware-times
Time columns should support time zone aware attributes
Diffstat (limited to 'activerecord/lib/active_record/type/time.rb')
-rw-r--r-- | activerecord/lib/active_record/type/time.rb | 13 |
1 files changed, 13 insertions, 0 deletions
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) |