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/*