From: thefed Date: 2007-12-03T06:18:17+09:00 Subject: Re: Name this method... On Dec 2, 2007, at 3:58 PM, Daniel Waite wrote: > First off, if there's already a method that does this please point it > out; I couldn't find one so I wrote my own. > > It's currently called #to_elapsed_time and is attached to Fixnum. What > it does... > >>> 10.to_elapsed_time > => {:days=>0, :minutes=>0, :seconds=>10, :hours=>0} >>> 75.to_elapsed_time > => {:days=>0, :minutes=>1, :seconds=>15, :hours=>0} >>> 75018.to_elapsed_time > => {:days=>0, :minutes=>50, :seconds=>18, :hours=>20} >>> 789010.to_elapsed_time > => {:days=>9, :minutes=>10, :seconds=>10, :hours=>3} That's DEFINITELY a nice method to have around :-) Unfortunately.... > started = Time.now > ended = Time.now + some_time_into_the_future > elapsed = (ended.to_i - started.to_i).to_elapsed_time puts ended - started #=> Some Time already works Don't trash your method though! It will probably come in handy one day Ari Brown --------------------------------------------| If you're not living on the edge, then you're just wasting space.