module Hizuke::HolidayCalculator
def calculate_christmas_date
-
(Date)
- the date for Christmas this year
def calculate_christmas_date current_year = Date.today.year christmas_date = Date.new(current_year, 12, 25) # If Christmas has already passed this year, return next year's Christmas if Date.today > christmas_date Date.new(current_year + 1, 12, 25) else christmas_date end end
def calculate_holiday_date(date_value)
-
(Date)
- the calculated date
Parameters:
-
date_value
(Symbol
) -- the date keyword (:christmas, :next_christmas, or :last_christmas)
def calculate_holiday_date(date_value) case date_value when :christmas calculate_christmas_date when :next_christmas calculate_next_christmas_date when :last_christmas calculate_last_christmas_date end end
def calculate_last_christmas_date
-
(Date)
- the date for Christmas last year
def calculate_last_christmas_date current_year = Date.today.year Date.new(current_year - 1, 12, 25) end
def calculate_next_christmas_date
-
(Date)
- the date for Christmas next year
def calculate_next_christmas_date current_year = Date.today.year Date.new(current_year + 1, 12, 25) end