David Bird
2008-Jun-23 09:23 UTC
''ArgumentError: bad value for range'' for range of Times
Hi, 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...>> 38.years.ago..10.years.ago=> Tue Jun 23 19:12:11 +1000 1970..Tue Jun 23 19:12:11 +1000 1998>> 39.years.ago..10.years.ago=> ArgumentError: bad value for range Any ideas? Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-23 09:31 UTC
Re: ''ArgumentError: bad value for range'' for range of Times
On 23 Jun 2008, at 10:23, David Bird wrote:> > Hi, > > 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... > >>> 38.years.ago..10.years.ago > => Tue Jun 23 19:12:11 +1000 1970..Tue Jun 23 19:12:11 +1000 1998 > >>> 39.years.ago..10.years.ago > => 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. Fred> Any ideas? > > Thanks > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Bird
2008-Jun-23 10:26 UTC
Re: ''ArgumentError: bad value for range'' for range of Times
Thanks, Fred. Much appreciated. On Jun 23, 7:31 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 Jun 2008, at 10:23, David Bird wrote: > > > > > Hi, > > > 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... > > >>> 38.years.ago..10.years.ago > > => Tue Jun 23 19:12:11 +1000 1970..Tue Jun 23 19:12:11 +1000 1998 > > >>> 39.years.ago..10.years.ago > > => 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. > > Fred > > > Any ideas? > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---