diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-05-20 16:33:09 +0100 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-05-20 16:36:25 +0100 |
commit | 28938dd64c8b4fa1943d0b878d3d832b94fa12a3 (patch) | |
tree | fb444105f088ecee23471d5f045f43dfe4e23546 /Gemfile | |
parent | 1c2dd9cb66ceda3c8febfed4f3f2cb39ae92bd4a (diff) | |
download | rails-28938dd64c8b4fa1943d0b878d3d832b94fa12a3.tar.gz rails-28938dd64c8b4fa1943d0b878d3d832b94fa12a3.tar.bz2 rails-28938dd64c8b4fa1943d0b878d3d832b94fa12a3.zip |
Fix implicit calculations with scalars and durations
Previously calculations where the scalar is first would be converted
to a duration of seconds but this causes issues with dates being
converted to times, e.g:
Time.zone = "Beijing" # => Asia/Shanghai
date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
2 * 1.day # => 172800 seconds
date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00
Now the `ActiveSupport::Duration::Scalar` calculation methods will try
to maintain the part structure of the duration where possible, e.g:
Time.zone = "Beijing" # => Asia/Shanghai
date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017
2 * 1.day # => 2 days
date + 2 * 1.day # => Mon, 22 May 2017
Fixes #29160, #28970.
Diffstat (limited to 'Gemfile')
0 files changed, 0 insertions, 0 deletions