require 'date'
def date_of_next(day_name)
date = Date.parse(day_name)
delta = date > Date.today ? 0 : 7
date + delta
end
Date.today
#=>#<Date: 2011-10-28 (4911725/2,0,2299161)>
date_of_next "Monday"
#=>#<Date: 2011-10-31 (4911731/2,0,2299161)>
date_of_next "Sunday"
#=>#<Date: 2011-10-30 (4911729/2,0,2299161)>
Last active
June 21, 2017 13:13
-
-
Save marcelosantos/53a2303aa537bbf851ae755ffea15ecb to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment