EB
10/24/2006 11:57:00 AM
Ok, I try to use ruby for all sorts on-the-fly things as
they come up so that I can practice & learn about it :-)
So, I'm looking up Ruby in a Nutshell, and amazon says
if I order in the next 10 hours and 40 minutes I can get
it soon.
"Cool" I think .. "I can use Ruby to do the time math",
and irb is my friend :-)
However, I can't get it to work. This is what I tried:
irb(main):001:0> now=Time.now
=> Tue Oct 24 07:49:31 -0400 2006
irb(main):002:0> hours = 10
=> 10
irb(main):003:0> mins = 40
=> 40
irb(main):004:0> total_minutes = hours * 60 + mins
=> 640
irb(main):005:0> now
=> Tue Oct 24 07:49:31 -0400 2006
irb(main):006:0> now.min
=> 49
irb(main):007:0> now.min + total_minutes
=> 689
irb(main):008:0> now + total_minutes
=> Tue Oct 24 08:00:11 -0400 2006
irb(main):009:0> now
=> Tue Oct 24 07:49:31 -0400 2006
Is there an easy way to add specific hours and minutes to a
given time? I have a feeling this is easy to do, I just don't
know how.
Thanks,
eb