diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2017-03-16 08:53:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-16 08:53:12 +0000 |
commit | ee33b9e93a5a06aa6c312466576b91ed210cf7c0 (patch) | |
tree | 85548d355856304027b972641775548e15e8abce /activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb | |
parent | f38de5a7b4ea56c8f9f9138248128339a53a1b1f (diff) | |
parent | 92fc8ec663f7dbb554c42dd41a86a7efe63dc725 (diff) | |
download | rails-ee33b9e93a5a06aa6c312466576b91ed210cf7c0.tar.gz rails-ee33b9e93a5a06aa6c312466576b91ed210cf7c0.tar.bz2 rails-ee33b9e93a5a06aa6c312466576b91ed210cf7c0.zip |
Merge pull request #28147 from kmcphillips/master-time-freeze
Allow Time#to_time on frozen objects. Return frozen time rather than "RuntimeError: can't modify frozen Time"
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb b/activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb index db95ae0db5..3f4e236ab7 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb @@ -12,11 +12,7 @@ module DateAndTime mattr_accessor(:preserve_timezone, instance_writer: false) { false } def to_time - if preserve_timezone - @_to_time_with_instance_offset ||= getlocal(utc_offset) - else - @_to_time_with_system_offset ||= getlocal - end + preserve_timezone ? getlocal(utc_offset) : getlocal end end end |