#!/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}"
if min_birth > max_birth
puts "You're too young ^__^"
end
Originally published at Chase your dream!. You can comment here or there.