Files
nairobi/lib/date_ext.rb
2017-02-03 12:46:07 +01:00

9 lines
301 B
Ruby

module AgeInYears
def age_in_years(now = Time.now.utc.to_date)
# reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263
now.year - year - ((now.month > month || (now.month == month && now.day >= day)) ? 0 : 1)
end
end
Date.include(AgeInYears)