rails/rails — pull request #17810 by bogdan (2014-11-28 13:05:43+00:00)
Title: Nanoseconds support for DateTime#end_of_* methods

The behaviour of DateTime#end_of_* methods is different from
Time#end_of_*. DateTime unlike Time doesn't take seconds fraction into count.

``` ruby
Time.now.end_of_day.usec # => 999999.999
DateTime.now.end_of_day.usec # => 0
```

It leads into unexpected behaviour like:

``` ruby
DateTime.now.end_of_day.to_time == Time.now.end_of_day # => false

class Campaign < ActiveRecord::Base; end

Campaign.create!(..., finishes_at: Time.now.end_of_month)
Campaign.where(finishes_at: DateTime.now.end_of_month) # => []
```

This patch makes the behaviour of these methods consistent for both classes, so that Time and DateTime become more mutually changeable.