Closed cgriego closed 13 years ago
This is a bug in ActiveSupport and should be reported on the rails bugtracker. The fact that Date#<=> works with DateTime instances is an implementation detail that shouldn't be relied on. See https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6321 (the RDoc for Date#<=>), it doesn't mention DateTime.
Thanks for the input. I opened a pull request on ActiveSupport. https://github.com/rails/rails/pull/2797
I ran into another incompatibility with ActiveSupport 3.1, but I had to fight through tzinfo to get there. This time, it's an undocumented difference between home_run and stdlib. The difference is that DateTime has its own implementation of <=> rather than inheriting it from Date. Here is a minimal test case:
Isn't that neat how the DateTime changed from year 1967 to year 67503?
ActiveSupport is affected by this difference because it has this code:
Older versions of ActiveSupport used alias_method chains to achieve the same effect, which doesn't trigger the difference from stdlib. I'm not sure what action you'll want to take, but at the very least this should be documented.