diff options
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f1759aa68f..d1729b6ff4 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2470,8 +2470,12 @@ module ActiveRecord #:nodoc: end # Includes an ugly hack for Time.local instead of Time.new because the latter is reserved by Time itself. - def instantiate_time_object(*values) - @@default_timezone == :utc ? Time.utc(*values) : Time.local(*values) + def instantiate_time_object(name, values) + if Time.zone && !self.class.skip_time_zone_conversion_for_attributes.include?(name.to_sym) + Time.zone.new(*values) + else + @@default_timezone == :utc ? Time.utc(*values) : Time.local(*values) + end end def execute_callstack_for_multiparameter_attributes(callstack) @@ -2483,12 +2487,12 @@ module ActiveRecord #:nodoc: else begin value = if Time == klass - instantiate_time_object(*values) + instantiate_time_object(name, values) elsif Date == klass begin Date.new(*values) rescue ArgumentError => ex # if Date.new raises an exception on an invalid date - instantiate_time_object(*values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates + instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates end else klass.new(*values) |