Checking to see if a day/hour/whatever has passed

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…

On 12/27/07, Mike C [email protected] 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 D.
http://destiney.com/

I think that would be Time…thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs