Year/Month diff feature

As you can see on this SO posts, there are plenty of ways to go wrong doing a diff of month in rails.

Since we already have the Time.days_in_year and Time.days_in_month feature, we could do a pretty accurate Float diff between months or years (days / hours / minutes beeing trivial).

However, maybe the Float result is only something I needed for my very specific case (computed cost per month based on a period).

So here are my questions:

  • would you want a date diff feature ?
  • if yes, would you want a float result ?

Interface very rough idea: time_1.months_from(time_2); time_1.days_from(time_2)

@ulysse this is definitely an interesting idea. I’m not sure why you’d stop at only months or years, though. I think this feature could provide benefit to find any difference in DateTime.