Created
July 8, 2017 05:14
-
-
Save theHamdiz/14f2b561e238d6f4579e4acba85b29eb to your computer and use it in GitHub Desktop.
Get to know your next 'n' number of birthdays including the name of the day its occurring on.
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 my_next_n_birthdays(number_of_years = 60, birthday = 24, birth_month = 8) | |
lazy_dates = (Date.today..Date.new(9999)).lazy | |
my_next_birthdays = lazy_dates.select { |d| d.day == birthday and d.month == birth_month }.first(number_of_years).map { |date| "#{date.strftime('%A')} - #{date}"} | |
end | |
puts my_next_n_birthdays |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment