On Fri, Apr 06, 2007 at 06:00:50PM +0900, Dipesh Batheja wrote:
> Hi,
> Is there any instance method in Ruby for Date type, to find previous
> date. For example if I have date - "04/05/07" in an object "date", then
> something like "date.previous" returns me date - "04/04/07".

The Date object can inherently do date arithmetic:

    irb(main):001:0> require 'date'
    irb(main):002:0> today = Date.today
    irb(main):003:0> yesterday = today - 1
    irb(main):004:0> puts "Today : #{today}"
    Today : 2007-04-06
    irb(main):006:0> puts "Yesterday : #{yesterday}"
    Yesterday : 2007-04-05

So if you would like a today.prev then you can easily add #prev.
Date#succ already exists.

    class Date
        def prev
            self - 1
        end
    end

If you want even more interesting time/date utility functions add in the
facets gem and try out the 'more/times' items, you can do things like
1.week.ago and 3.hours.from_now.

    http://facets.rubyforge.org/src/doc/rdoc/more/classes/Numeric.html

enjoy,

-jeremy

-- 
========================================================================
 Jeremy Hinegardner                              jeremy / hinegardner.org