Martin Fowler's Runt library is really handy for date/time comparisons, and this code works great in an irb console:
require 'runt'
include Runt
r_start = PDate.month(2010,12)
r_end = PDate.month(2011,12)
range = DateRange.new(r_start,r_end)
o_start = PDate.month(2010,11)
o_end = PDate.month(2012,2)
o_range = DateRange.new(o_start,o_end)
range.overlap?(o_range)
but if I add the Runt gem to my Rails 2.3.5 app and try to run the same commands in script/console, I get this error:
NoMethodError: undefined method
`to_datetime' for Mon, 01 Nov 2010
00:00:00 +0000..Wed, 01 Feb 2012
00:00:00 +0000:Runt::DateRange
from
/Users/jacob/work/matchbook/vendor/gems/runt-0.7.6/lib/runt/sugar.rb:130:in
method_missing' from
/Users/jacob/work/matchbook/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb:120:in
<=' from
/Users/jacob/work/matchbook/vendor/gems/runt-0.7.6/lib/runt/pdate.rb:91:in
<=>' from
/Users/jacob/work/matchbook/vendor/gems/runt-0.7.6/lib/runt/daterange.rb:34:in
member?' from
/Users/jacob/work/matchbook/vendor/gems/runt-0.7.6/lib/runt/daterange.rb:34:in
`overlap?' from (irb):10
Has anyone encountered this error before, or does anyone know how to begin debugging this? I've tried looking at the spaceship operator in the ActiveSupport calculations module, but I can't figure out how to pick apart the problem.
Thanks very much for your help,
Jacob