I want to check if an hour has passed since the current time. When I run return (DateTime.now > (@session[''user''].account_info.last_reward + 0.04)) it returns the correct value I think, but when I put that same thing (without the return) in an if statement, it tells me it can''t compare a datetime and a time. Not sure how to compare them then... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 12/27/07, Mike C <snibble-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I want to check if an hour has passed since the current time. When I > run > return (DateTime.now > (@session[''user''].account_info.last_reward + > 0.04)) > > it returns the correct value I think, but when I put that same thing > (without the return) in an if statement, it tells me it can''t compare > a datetime and a time. Not sure how to compare them then...You have to convert one to the other''s same class.>> DateTime.now.class=> DateTime What does this say? (@session[''user''].account_info.last_reward + 0.04).class -- Greg Donald http://destiney.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 -~----------~----~----~----~------~----~------~--~---
I think that would be Time...thanks! On Dec 27, 9:25 am, "Greg Donald" <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12/27/07, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I want to check if an hour has passed since the current time. When I > > run > > return (DateTime.now > (@session[''user''].account_info.last_reward + > > 0.04)) > > > it returns the correct value I think, but when I put that same thing > > (without the return) in an if statement, it tells me it can''t compare > > a datetime and a time. Not sure how to compare them then... > > You have to convert one to the other''s same class. > > >> DateTime.now.class > > => DateTime > > What does this say? > > (@session[''user''].account_info.last_reward + 0.04).class > > -- > Greg Donaldhttp://destiney.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---