Module: AgeCalcs

Defined in:
lib/age_calcs.rb,
lib/age_calcs/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.find_age(year, month, day) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/age_calcs.rb', line 7

def self.find_age(year, month, day)
  birthdate = Time.new(year, month, day)
  seconds = (Time.now - birthdate).to_i
  mm, ss = seconds.divmod(60)
  hh, mm = mm.divmod(60)
  dd, hh = hh.divmod(24)
  year_of_age = dd/365
  rem_days = dd%365
  rem_months = rem_days/31
  puts "Running Age: #{year_of_age} and #{rem_months} th Month."
end