Hi! I had this idea, hope it helps:

class Date
  def elapsedYearsAndDays(rangeDate)
    if self > rangeDate
      startDate = rangeDate.clone  #clone the values so they are not 
changed unintentionally
      endDate = self.clone
    else
      startDate = self.clone
      endDate = rangeDate.clone
    end
    magicDay = (startDate.month == 2) && (startDate.day == 29)    #This 
is the real problem: Febraury 29th!
    startDate += 1 if !endDate.leap? && magicDay
    elapsedYears = endDate.year - startDate.year
    previousStartDate = Date.new(endDate.year, startDate.month, 
startDate.day)
    if endDate < previousStartDate
      elapsedYears -= 1
      previousStartDate = Date.new(endDate.year - 1, startDate.month, 
startDate.day)
      previousStartDate -= 1 if previousStartDate.leap? && magicDay
    end
    elapsedDays = endDate - previousStartDate
    return elapsedYears, elapsedDays
  end
end

elapsedYears, elapsedDays = 
Date.today.elapsedYearsAndDays(Date.new(1963, 11, 22))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(1963, 11, 
22).elapsedYearsAndDays(Date.new(1963, 11, 22))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(2007, 3, 
1).elapsedYearsAndDays(Date.new(2004, 3, 1))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(2004, 3, 
1).elapsedYearsAndDays(Date.new(2001, 3, 2))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(2004, 2, 
29).elapsedYearsAndDays(Date.new(2001, 3, 1))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(2004, 3, 
1).elapsedYearsAndDays(Date.new(2001, 3, 1))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"

elapsedYears, elapsedDays = Date.new(2004, 2, 
29).elapsedYearsAndDays(Date.new(2009, 3, 1))
daysMessage = (elapsedDays > 0) ? (" and #{elapsedDays} day(s)") : ""
puts "Elapsed time: #{elapsedYears} year(s)#{daysMessage}"


-- 
Posted via http://www.ruby-forum.com/.