a = Time.new
b = Time.mktime(1984, 2, 29, 15, 15)
seconds = a.to_i-b.to_i
minutes = seconds.to_i/60
hours = minutes.to_i/60
days = hours.to_i/24
weeks = days.to_i/7
months = weeks.to_i/4
years = seconds.to_i/31556925 #approximate number of seconds per year. Not going to be completely accurate.
Mon Jul 20 03:59:43 -0500 2009 <—-Current date
Wed Feb 29 15:15:00 -0600 1984 <—-Birthday
27 <—-Years
331 <—-Months
1324 <—-Weeks
9272 <—-Days
222539 <—-Hours
13352384 <—-Minutes
801143083 <—-Seconds
Type quit to exit this program. Or hit enter to update your current age.
Notice the numbers there are quite wrong. I'm not 27 years old I'm 25 for starters.
Here's the code. Hopefully someone can find what I messed up. It may just be my math that's screwy right now.
Please point out what I did wrong here.
[edit to add] I should clarify what I want the program to do here. I want it to eventually say "You are XX years XX months XX weeks XX days and XX seconds old.".