Vulpo One

Am I completely lost to society?

image0

#!/usr/bin/ruby

require 'date'

puts "Enter your birthdate (YYYY-MM-DD):"
birth = Date.parse(gets, true)
today = Date.today
age   = today-birth # in days

min_age = (2 * (age - 7 * 365.25)).round
max_age = (age/2 + 7 * 365.25).round

min_birth = Date.today - min_age
max_birth = Date.today - max_age

puts "Your age pool is #{min_birth.to_s} - #{max_birth.to_s}"

puts "You're too young ^__^" if min_birth > max_birth

Comments