From: "Jesús Gabriel y Galán" Date: 2008-04-17T00:01:42+09:00 Subject: Re: Calculating elapsed time On Wed, Apr 16, 2008 at 4:47 PM, Rob Biedenharn wrote: > or: > irb> start = Time.now > => Wed Apr 16 10:41:03 -0400 2008 > irb> finish = Time.now > => Wed Apr 16 10:45:53 -0400 2008 > irb> elapsed = finish.to_f - start.to_f # note to_f to keep fractional > seconds Yep, I assumed he wanted to stop at the seconds level. > => 289.695813894272 > irb> mins, secs = elapsed.divmod 60.0 > => [4, 49.6958138942719] > irb> puts("%3d:%04.2f"%[mins.to_i, secs]) > 4:49.70 > => nil I always forget about divmod, it's a cool little method :-) Jesus.