-----Original Message-----
From: A LeDonne [mailto:
[email protected]]
Sent: January 29, 2006 9:15 PM
To: ruby-talk ML; (e-mail address removed)
Subject: Re: relative dates
Thanks, I had no idea that it was so simple in Ruby!
today = Time.now
puts (today - 7)
Careful!
If you're using Time, you're subtracting SECONDS:
irb(main):001:0> today = Time.now
=> Mon Jan 30 00:11:51 EST 2006
irb(main):002:0> puts( today - 7 )
Mon Jan 30 00:11:44 EST 2006
=> nil
That's why I included the " require 'date' " in my example,
and suggested that you could use DateTime if you needed times.
I thought I would have to write the method myself!