'ArgumentError: bad value for range' for range of Times


When using the calendar_date_select plugin, Rails kept throwing an
ArgumentError: ‘bad value for range’, but only on Windows (fine on
OSX). Playing around in the console I get…

=> Tue Jun 23 19:12:11 +1000 1970…Tue Jun 23 19:12:11 +1000 1998

=> ArgumentError: bad value for range

Any ideas?


On 23 Jun 2008, at 10:23, David Bird wrote:

=> ArgumentError: bad value for range

Time only covers a reasonably small range. On OS X, the smallest time
representable is 1st January 1901, but I’m guessing that on windows
it’s 1st jan 1970. DateTime is a native ruby thing that can represent
pretty much any date, and xxx.years.ago will fallback to that if
necessary. What I’m guessing is happening is that 39.years.ago…
10.years.ago will wind up trying to create a range where one endpoint
is an instance of DateTime and the other is a Time, which ruby doesn’t
like. If that’s the case then forcing both ends to instances of
DateTime (to_datetime) should do the trick.


Thanks, Fred. Much appreciated.

On Jun 23, 7:31 pm, Frederick C. [email protected]