This project is archived and is in readonly mode.
[PATCH] DateTime#to_date returns self when Date#to_date is defined at first
Reported by Raimonds Simanovskis | February 16th, 2010 @ 07:57 PM
On Ruby 1.8.7 DateTime#to_date returns self due to the following bug.
As active_support/time.rb loads active_support/core_ext/date/conversions before active_support/core_ext/date_time/conversions then DateTime#to_date method is not defined as DateTime.method_defined?(:to_date) is true as Date#to_date method is already defined and DateTime inherits to_date method from Date.
There is similar issue with DateTime#xmlschema method definition.
Included patch fixes conditions for DateTime#to_date and DateTime#xmlschema definition to check if method is defined for DateTime and is not just inherited. Included patch also removes requiring 'active_support/ruby/shim' in abstract_unit.rb when using Ruby 1.8.7 to ensure the same sequence of requires as in real Rails applications.
Comments and changes to this ticket
-
Raimonds Simanovskis February 16th, 2010 @ 08:15 PM
Updated patch to also include correct condition for DateTime#to_datetime method definition.
-
Greg Campbell April 13th, 2010 @ 07:54 AM
This patch appears to work, except that without the shim we now need to explicitly require active_support/core_ext/file/path for test/core_ext/file_test.rb to pass. I've attached a second patch which does only that.
-
Ryan Bigg June 12th, 2010 @ 02:54 AM
- State changed from new to resolved
Greg, I don't see how that patch relates to this issue. I'm going to close this ticket and hope you've attached that patch to the right ticket.
-
Raimonds Simanovskis June 19th, 2010 @ 08:00 AM
This patch was applied to master branch therefore it's OK to close this ticket
http://github.com/rails/rails/commit/5fcaf917612c61174f55bbd2301131...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 4204 DateTime arithmetic: Stack level too deep This is reproducible on my machine. I believe it should b...
- 4204 DateTime arithmetic: Stack level too deep This was fixed by this commit, which applied the patch f...