From: ara.t.howard@... Date: 2006-09-06T23:25:48+09:00 Subject: Re: [ANN] timeunits-0.0.0 On Wed, 6 Sep 2006, Rimantas Liubertas wrote: > <...> >> >>> delta = b - a >> > => 42.0 >> >>> p delta.days >> > 3628800.0 >> > => nil >> >> right. that is totally wrong. the difference is only 42 seconds, therefor >> it >> should be a fractional day. eg. > <...> > > 'days' and similar methods in Rails are core extensions and return > number of seconds. > So 42.days returns number of seconds in 42 days. > > Useful for things like: > >>> 10.minutes.ago > => Wed Sep 06 12:56:52 FLE Daylight Time 2006 >>> 3.days.since > => Sat Sep 09 13:06:58 FLE Daylight Time 2006 thanks, i realize that. this little extension does both: harp:~ > cat a.rb require 'timeunits' a = Time.now.utc b = a + 42.days # like rails, facets, etc. p a p b delta = b - a p delta.days # inverse operation harp:~ > ruby a.rb Wed Sep 06 14:23:29 UTC 2006 Wed Oct 18 14:23:29 UTC 2006 42.0 not that computing 'days' on a difference is the inverse operation (/) as compared to when doing in a summation ('*'). regards. -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