Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Created July 8, 2017 05:14
Show Gist options
  • Save theHamdiz/14f2b561e238d6f4579e4acba85b29eb to your computer and use it in GitHub Desktop.
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.
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