users_helper.rb 297 B

123456789101112
  1. module UsersHelper
  2. def age_in_completed_years (bd)
  3. # Difference in years, less one if you have not had a birthday this year.
  4. d = Date.today.year
  5. a = d - bd.year
  6. a = a - 1 if (
  7. bd.month > d.month or
  8. (bd.month >= d.month and bd.day > d.day)
  9. )
  10. a
  11. end
  12. end