class NxtSupport::BirthDate
Public Instance Methods
to_age(today = Date.current)
click to toggle source
# File lib/nxt_support/util/birth_date.rb, line 6 def to_age(today = Date.current) today.year - date.year - (today.month > date.month || (today.month == date.month && today.day >= date.day) ? 0 : 1) end
to_age_in_months(today = Date.current)
click to toggle source
# File lib/nxt_support/util/birth_date.rb, line 10 def to_age_in_months(today = Date.current) (today.year * 12 + today.month) - (date.year * 12 + date.month) end
to_date()
click to toggle source
# File lib/nxt_support/util/birth_date.rb, line 14 def to_date date end
Private Instance Methods
parse_date(date_or_string)
click to toggle source
# File lib/nxt_support/util/birth_date.rb, line 20 def parse_date(date_or_string) date_or_string.is_a?(Date) ? date_or_string : Date.parse(date_or_string) end