On Wednesday, September 06, 2006, at 6:43 AM, wrote: > >we've all written bits of it before, here it is for that don't want to: > > >NAME > > timeunits.rb > >URIS > > http://rubyforge.org/projects/codeforpeople/ > http://codeforpeople.org/lib/ruby/ > >SYNOPSIS > > adds methods to Numeric and Time classes to support time units and time > difference units. > >EXAMPLE > > harp:~ > cat a.rb > require "timeunits" > require "yaml" > > now = Time::now > > a = now > y "a" => a > > b = now + 2.hours + 2.minutes > y "b" => b > > d = b - a > %w( seconds minutes hours days ).each do |unit| > y "d.#{ unit }" => d.send(unit) > end > > harp:~ > ruby a.rb > a: 2006-09-05 15:33:23.697319 -06:00 > b: 2006-09-05 17:35:23.697319 -06:00 > d.seconds: 7320.0 > d.minutes: 122.0 > d.hours: 2.03333333333333 > d.days: 0.0847222222222222 > >DOCS > > see lib/* > > >enjoy. > >-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 > FWIW, Rails already does this, as does Facets, the conversions gem, and the ruby-units gem. The API varies a little bit. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.