Tim Hunter
7/3/2007 2:36:00 PM
On Jul 3, 10:13 am, "Ben Edwards" <funkyt...@gmail.com> wrote:
> I have a date
>
> my_date = Date.new( 2007, 1, 1 )
>
> I then have a variable holding an integer
>
> months_to_add = 4
>
> How do i add 'months_to_add' to my_date'?
>
> I have spent ages googeling and looking in o'reilly ruby cookbook but no luck;(
>
> Any ideas?
My first question is "which 4 months?" Adding January, February,
March, and April is different from adding June, July, and August and
September.
However, let's assume that you know which four and can determine the
number of days in your 4 months. According to ri, Date defines the "+"
method, so it should be as simple as
my_new_date = my_date + days_to_add