diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-18 13:55:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-18 13:55:13 +0900 |
commit | aeba121a83965d242ed6d7fd46e9c166079a3230 (patch) | |
tree | 6dc49f839a9e41cd68eb34ec01ed69350829afbf /activemodel/lib/active_model | |
parent | c65acad0df6b332324c24e725c7d581bd76f9760 (diff) | |
parent | d29d4598972e85df7ee42f5aa969b51d1b14d615 (diff) | |
download | rails-aeba121a83965d242ed6d7fd46e9c166079a3230.tar.gz rails-aeba121a83965d242ed6d7fd46e9c166079a3230.tar.bz2 rails-aeba121a83965d242ed6d7fd46e9c166079a3230.zip |
Merge pull request #36508 from kamipo/avoid_getutc
Avoid redundant `time.getutc` call if it is already utc time object
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/type/helpers/time_value.rb | 8 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/value.rb | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb index 508fe77531..075e906034 100644 --- a/activemodel/lib/active_model/type/helpers/time_value.rb +++ b/activemodel/lib/active_model/type/helpers/time_value.rb @@ -11,10 +11,10 @@ module ActiveModel value = apply_seconds_precision(value) if value.acts_like?(:time) - zone_conversion_method = is_utc? ? :getutc : :getlocal - - if value.respond_to?(zone_conversion_method) - value = value.send(zone_conversion_method) + if is_utc? + value = value.getutc if value.respond_to?(:getutc) && !value.utc? + else + value = value.getlocal if value.respond_to?(:getlocal) end end diff --git a/activemodel/lib/active_model/type/value.rb b/activemodel/lib/active_model/type/value.rb index 994d135b7b..788ded3e96 100644 --- a/activemodel/lib/active_model/type/value.rb +++ b/activemodel/lib/active_model/type/value.rb @@ -110,7 +110,7 @@ module ActiveModel [self.class, precision, scale, limit].hash end - def assert_valid_value(*) + def assert_valid_value(_) end private |