Created
September 23, 2018 12:31
-
-
Save harrisonmalone/b0930b029c3c3e19ab5655bf6035b832 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'date' | |
def days_since_born(year, month, day) | |
date = Date.new(year, month, day) | |
p date | |
today = Date.today | |
p today | |
result = (today - date).to_i | |
sentence = "I have been alive for #{result} days" | |
return sentence | |
end | |
p days_since_born(1993, 03, 30) | |
# remember that you can subtract two different date objects to get the difference in date, all you need is a to_i to convert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment