Created
October 9, 2019 08:20
-
-
Save arthur-littm/021eabfcf74691b8efcad51244d7c7aa to your computer and use it in GitHub Desktop.
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
require "date" | |
def days_until_xmas() | |
# PSEUDO CODE | |
# 1. require date | |
# 2. set a variable with today's date | |
todays_date = Date.today | |
# 3. set another variable with xmas date (of this year) | |
xmas_date = Date.new(todays_date.year, 12, 25) | |
if todays_date > xmas_date | |
xmas_date = Date.new(todays_date.year + 1, 12, 25) | |
end | |
# 4. calculate difference betwe o | |
diff = (xmas_date - todays_date).to_i | |
# 5. return the answer | |
return diff | |
end | |
# Test the method below: | |
puts days_until_xmas().class == Integer | |
puts days_until_xmas() == 78 | |
puts days_until_xmas | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment