diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-10-21 07:03:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-21 07:03:32 +0100 |
commit | f2c6db41ba56afb1529e4732c59622fc0cf9f3ba (patch) | |
tree | 75abdc2e5c40ece261b1db41ee1a1b7f61eefd5e /activesupport | |
parent | dce4751a74342bd94802eb49b411663b66ace28b (diff) | |
parent | fc72d6815ad6ed447f1aea2dd98579305ea1cca4 (diff) | |
download | rails-f2c6db41ba56afb1529e4732c59622fc0cf9f3ba.tar.gz rails-f2c6db41ba56afb1529e4732c59622fc0cf9f3ba.tar.bz2 rails-f2c6db41ba56afb1529e4732c59622fc0cf9f3ba.zip |
Merge pull request #26839 from renuo/fix-missing-nsec-transfer
Fix copy_time_to: Copy nsec instead of usec
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/calculations.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/date_and_time_behavior.rb | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index f840783059..91dfc556d3 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,9 @@ +* Fix `DateAndTime::Calculations#copy_time_to`. Copy `nsec` instead of `usec`. + + Jumping forward or backward between weeks now preserves nanosecond digits. + + *Josua Schmid* + * Fix `ActiveSupport::TimeWithZone#in` across DST boundaries. Previously calls to `in` were being sent to the non-DST aware diff --git a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb index c614f14289..f2ba7fdda5 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb @@ -334,7 +334,7 @@ module DateAndTime end def copy_time_to(other) - other.change(hour: hour, min: min, sec: sec, usec: try(:usec)) + other.change(hour: hour, min: min, sec: sec, nsec: try(:nsec)) end end end diff --git a/activesupport/test/core_ext/date_and_time_behavior.rb b/activesupport/test/core_ext/date_and_time_behavior.rb index bf83ac602f..6cc9781e02 100644 --- a/activesupport/test/core_ext/date_and_time_behavior.rb +++ b/activesupport/test/core_ext/date_and_time_behavior.rb @@ -126,7 +126,9 @@ module DateAndTimeBehavior end def test_next_week_at_same_time - assert_equal date_time_init(2005,2,28,15,15,10), date_time_init(2005,2,22,15,15,10).next_week(:monday, same_time: true) + assert_equal date_time_init(2005,2,28,15,15,10), date_time_init(2005,2,22,15,15,10).next_week(:monday, same_time: true) + assert_equal date_time_init(2005,2,28,15,15,10,999999), date_time_init(2005,2,22,15,15,10,999999).next_week(:monday, same_time: true) + assert_equal date_time_init(2005,2,28,15,15,10,Rational(999999999, 1000)), date_time_init(2005,2,22,15,15,10,Rational(999999999, 1000)).next_week(:monday, same_time: true) assert_equal date_time_init(2005,3,4,15,15,10), date_time_init(2005,2,22,15,15,10).next_week(:friday, same_time: true) assert_equal date_time_init(2006,10,30,0,0,0), date_time_init(2006,10,23,0,0,0).next_week(:monday, same_time: true) assert_equal date_time_init(2006,11,1,0,0,0), date_time_init(2006,10,23,0,0,0).next_week(:wednesday, same_time: true) |