diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_and_time/zones.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/zones.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/zones.rb b/activesupport/lib/active_support/core_ext/date_and_time/zones.rb index e2432c8f8a..894fd9b76d 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/zones.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/zones.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DateAndTime module Zones # Returns the simultaneous time in <tt>Time.zone</tt> if a zone is given or @@ -22,19 +24,18 @@ module DateAndTime if time_zone time_with_zone(time, time_zone) else - time || self.to_time + time || to_time end end private - def time_with_zone(time, zone) - if time - ActiveSupport::TimeWithZone.new(time.utc? ? time : time.getutc, zone) - else - ActiveSupport::TimeWithZone.new(nil, zone, to_time(:utc)) + def time_with_zone(time, zone) + if time + ActiveSupport::TimeWithZone.new(time.utc? ? time : time.getutc, zone) + else + ActiveSupport::TimeWithZone.new(nil, zone, to_time(:utc)) + end end - end end end - |