Hi,

I want to add a given time difference to an Time object. My first idea was
to calculate the number of seconds of this time difference. This works for
values like hours or days, but when I want to add a month, the number of
seconds depends on the number of days in the given month.
My second idea was to use a vector to add the time:

 @@sec = Vector[ 0, 0, 0, 0, 0, 1 ]
 @@min = Vector[ 0, 0, 0, 0, 1, 0 ]
 @@hour = Vector[ 0, 0, 0, 1, 0, 0 ]
 @@day = Vector[ 0, 0, 1, 0, 0, 0 ]
 @@week = Vector[ 0, 0, 7, 0, 0, 0 ]
 @@month = Vector[ 0, 1, 0, 0, 0, 0 ]
 @@year = Vector[ 1, 0, 0, 0, 0, 0 ]

 def next! ( distance = @@year )
  return @next if ( 0 == distance )
  now = Time.now()
  values = Vector[ @next.year, @next.mon, @next.day,
   @next.hour, @next.min, @next.sec ]
  while ( @next.to_i() < now.to_i() )
   values += distance
   @next = Time.local( *values.to_a )
  end
  return @next
 end

But this can result in an "argument out of range" error.

Has someone a simple solution for this problem?

Thanks,
Sven