Class: Age

Inherits:
Object
  • Object
show all
Defined in:
lib/a1521hk_age.rb

Class Method Summary collapse

Class Method Details

.cal(year, month, day) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/a1521hk_age.rb', line 5

def self.cal(year,month,day)
  birthday = Date.new(year, month, day)
  today = Date.today

  age = today.year - birthday.year
  if today.month < birthday.month or (today.month == birthday.month and today.day < birthday.day)
    age -= 1
  end
  p age
end