jgeiger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-07 22:17 UTC
Rails dates and times, 40.years.ago
Simple test case: require ''rubygems'' require ''active_support'' puts 5.years.ago puts 40.years.ago It seems to be an issue on windows, as the linux version of the test below works just fine, but windows will crash with an ArgumentError: time must be positive. Does anyone have a solution/workaround so that I can create database queries that search for users older than 35 on my windows test box? Thank you. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jgeiger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> Simple test case: > require ''rubygems'' > require ''active_support'' > puts 5.years.ago > puts 40.years.ago > > It seems to be an issue on windows, as the linux version of the test > below works just fine, but windows will crash with an ArgumentError: > time must be positive. > > Does anyone have a solution/workaround so that I can create database > queries that search for users older than 35 on my windows test box? > > Thank you.The ''ruby-units'' gem can handle datetime math like this and will automagically convert to a DateTime from a Time when necessary. Using ruby-units, you would use ''40 years''.ago _Kevin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
puts Time.year.now-40 puts Time.year.now-80 it is another solution if u dont want upgrade your rails. Y Reinhart AP Teapoci.Blogspot.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---