Class: NxtSupport::BirthDate

Inherits:
Object
  • Object
show all
Includes:
NxtInit
Defined in:
lib/nxt_support/util/birth_date.rb

Instance Method Summary collapse

Instance Method Details

#to_age(today = Date.current) ⇒ Object



6
7
8
# 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) ⇒ Object



10
11
12
# 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_dateObject



14
15
16
# File 'lib/nxt_support/util/birth_date.rb', line 14

def to_date
  date
end