Skip to content

Instantly share code, notes, and snippets.

@piharpi

piharpi/main.rb

Created Mar 11, 2019
Embed
What would you like to do?
This find day of year by number
start_of_year = Time.new(2016, 1, 1)
# p start_of_year
# p start_of_year - 180 # second
# p start_of_year - (60 * 60 * 24)
def find_day_of_year_by_number(number)
current_date = Time.new(2016, 1, 1)
one_day = 60 * 60 * 24
until current_date.yday == number
current_date += one_day
end
current_date
end
p find_day_of_year_by_number(150)
p find_day_of_year_by_number(1)
p find_day_of_year_by_number(150)
p find_day_of_year_by_number(150)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment