Created
October 7, 2012 10:15
-
-
Save rvbsanjose/3847767 to your computer and use it in GitHub Desktop.
Birthday timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def birthday_timestamp(date) | |
date = date.split('/') | |
month, day, year = date.pop(3) | |
birthday = Time.mktime(year, month, day) | |
time_now = Time.now | |
years = time_now.year - birthday.year | |
months = time_now.month - birthday.month | |
days = time_now.day - birthday.day | |
puts "#{years} years #{-months} months #{-days} day old" if days < 2 | |
puts "#{years} years #{months} months #{days} days old" if days > 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment