Last active
February 28, 2016 06:30
-
-
Save DStorck/7a276743c3ea90839108 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
#oh the variables we we will use !! | |
days_in_a_year = 365.245 | |
minutes_in_a_year = 60 * 24 * days_in_a_year | |
#this time business was all new to me but i tried to set it for my birthday in NYC | |
my_age = Time.new(1980,9,7, 19, 44, 00, -0500) | |
now = Time.now | |
my_age_in_seconds = now - my_age | |
seconds_in_a_day = 60 * 60 * 24 | |
seconds_in_a_year = seconds_in_a_day * days_in_a_year | |
jeremy_age = 1136086041.6 / seconds_in_a_year | |
puts "There are #{days_in_a_year * 24} hours in a year." | |
puts "There are #{minutes_in_a_year * 10} minutes in a decade." | |
puts "I am #{my_age_in_seconds} seconds old." | |
puts "If Jeremy is telling the truth, he is #{jeremy_age} years old." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow, fancy use of the Time class and trying out timezone offsets! Also, I like how your my_age_in_seconds will update to the current time whenever this program is run.
Ruby allows you to do this neat thing with integers to make them more readable. If you want, try updating that giant number on line 12 to 1_136_086_041.6. The underscores take the place of commas, and make it easier for you / other devs to read giant nums.
Your variable names are very clear. Good work.