Timestamp difference

How would you find out whether the time difference of one timestamp is
greater than 5?

I've tried this

(old_time - Time.now) > 5

···

--
Posted via http://www.ruby-forum.com/.

How would you find out whether the time difference of one timestamp is
greater than 5?

I've tried this

(old_time - Time.now) > 5

and??

start = Time.now

=> Fri Jan 21 09:49:23 -0800 2011

stop = Time.now

=> Fri Jan 21 09:49:52 -0800 2011

(stop - start)

=> 29.616956

(stop - start) > 5

=> true

···

On Fri, Jan 21, 2011 at 9:46 AM, Benjamin Fowl <b.fowl87@gmail.com> wrote:

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

Try

(Time.now.to_i - old_time.to_i) > 5 # seconds

···

--
Posted via http://www.ruby-forum.com/.

In addition to the other responses, I'll point out that you have (past - now) which will always be <=0 the therefore NEVER > 5.

-Rob

Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab@GaslightSoftware.com http://GaslightSoftware.com/

···

On Jan 21, 2011, at 12:46 PM, Benjamin Fowl wrote:

How would you find out whether the time difference of one timestamp is
greater than 5?

I've tried this

(old_time - Time.now) > 5