[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: how to get 1 month in the future

Daniel Sheppard

1/12/2007 4:35:00 AM


> > require 'rubygems'
> > require_gem 'actionpack'
> > 1.month.from_now
> >
> > got to love actionpack.. :)
> >
> > ilan
>
>
> You just have to be aware that all that does is add 30 days to today's
> date.

The correct way to go about with active_support/action_pack/rails it is:

require 'rubygems'
require 'active_support'

time = Time.now.months_since(1)
or
time = Time.now.months.ago(-1)

Note that active_support is the library that you're after, not
actionpack (which is the library that provides the controller/view
behaviour of rails) - it just happened to work in the previous example
because actionpack requires active_support.


Dan.