From: ara.t.howard@... Date: 2006-09-06T10:04:24+09:00 Subject: Re: [ANN] timeunits-0.0.0 On Wed, 6 Sep 2006, Logan Capaldo wrote: > > On Sep 5, 2006, at 6:36 PM, ara.t.howard@noaa.gov wrote: > >> On Wed, 6 Sep 2006, Kevin Olbrich wrote: >> >>> FWIW, >>> >>> Rails already does this, as does Facets, the conversions gem, and the >>> ruby-units gem. >>> >>> The API varies a little bit. >> >> they do this? >> >> a = Time.now >> b = a + 42.seconds >> >> delta = b - a >> >> p delta.days #=> 0.000486111111111111 >> >> i didn't know they handled time differences too? i'm sure rails does not >> do >> this and the docs for facets seems to show it does not. are you sure? > > I'm not exactly sure what delta.days means in this case, but rails does the > following with your example: > > % script/console > Loading development environment. >>> a = Time.now > => Tue Sep 05 19:50:11 -0400 2006 >>> b = a + 42.seconds > => Tue Sep 05 19:50:53 -0400 2006 >>> delta = b - a > => 42.0 >>> p delta.days > 3628800.0 > => nil i just realized this might explain it better harp:~ > cat a.rb require 'yaml' require 'rubygems' require 'timeunits' a = Time.now.utc b = a + 42.seconds delta = b - a y 'delta.days' => delta.days pct_day = delta.days y 'seconds' => (pct_day * 1.day).seconds harp:~ > ruby a.rb delta.days: 0.000486111111111111 seconds: 42.0 -a -- what science finds to be nonexistent, we must accept as nonexistent; but what science merely does not find is a completely different matter... it is quite clear that there are many, many mysterious things. - h.h. the 14th dalai lama