mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Only call in_time_zone
on Time or DateTime instances
Both String and Date now respond to in_time_zone so we need to check if the value is a Time or a DateTime.
This commit is contained in:
parent
f0a9e2f852
commit
4dd5635922
1 changed files with 6 additions and 1 deletions
|
@ -2,6 +2,7 @@ require 'active_support/core_ext/class/attribute_accessors'
|
||||||
require 'active_support/core_ext/array/conversions'
|
require 'active_support/core_ext/array/conversions'
|
||||||
require 'active_support/core_ext/hash/conversions'
|
require 'active_support/core_ext/hash/conversions'
|
||||||
require 'active_support/core_ext/hash/slice'
|
require 'active_support/core_ext/hash/slice'
|
||||||
|
require 'active_support/core_ext/time/acts_like'
|
||||||
|
|
||||||
module ActiveModel
|
module ActiveModel
|
||||||
module Serializers
|
module Serializers
|
||||||
|
@ -20,7 +21,11 @@ module ActiveModel
|
||||||
|
|
||||||
def initialize(name, serializable, value)
|
def initialize(name, serializable, value)
|
||||||
@name, @serializable = name, serializable
|
@name, @serializable = name, serializable
|
||||||
value = value.in_time_zone if value.respond_to?(:in_time_zone)
|
|
||||||
|
if value.acts_like?(:time) && value.respond_to?(:in_time_zone)
|
||||||
|
value = value.in_time_zone
|
||||||
|
end
|
||||||
|
|
||||||
@value = value
|
@value = value
|
||||||
@type = compute_type
|
@type = compute_type
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue