Skip to content

Instantly share code, notes, and snippets.

@camcaine
Created January 7, 2011 12:12
Show Gist options
  • Save camcaine/769402 to your computer and use it in GitHub Desktop.
Save camcaine/769402 to your computer and use it in GitHub Desktop.
Calculate Age
def age
now = Time.now.utc.to_date
gap = (now.month > dob.month ||
(now.month == dob.month && now.day >= dob.day)) ? 0 : 1
now.year - dob.year - gap
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment