From: Steve Litt Date: 2005-12-15T00:32:05+09:00 Subject: Re: convert seconds to hours:minutes:seconds On Wednesday 14 December 2005 09:21 am, James Edward Gray II wrote: > On Dec 14, 2005, at 8:09 AM, Steve Litt wrote: > > #!/usr/bin/ruby > > b4 = Time.new > > sleep(3) > > after = Time.new > > interval = after.to_i - b4.to_i > > You can just subtract normally. Time knows what to do: > > interval = after - b4 > > > print "Started at ", b4.asctime, ", ended at ", after.asctime > > print "\n Interval is ", interval.to_s, ".\n" > > It's a good idea to get into the habit of using interpolation > with Ruby. That let's Ruby take care of stringifying your > values. We can also lose those \n characters: > > puts "Started at #{b4} and ended at #{after}." > puts "Interval is #{interval}." Confirmed! That's much cleaner. I've been looking for something like that, and didn't want to kill a kitten by using printf() :-) Thanks SteveT Steve Litt http://www.troubleshooters.com slitt@troubleshooters.com