module Hizuke::MonthCalculator
def calculate_last_month_date
-
(Date)
- the first day of the previous month
def calculate_last_month_date # Return the first day of the previous month prev_month = Date.today << 1 Date.new(prev_month.year, prev_month.month, 1) end
def calculate_month_date(date_value)
-
(Date)
- the calculated date
Parameters:
-
date_value
(Symbol
) -- the date keyword (:next_month or :last_month)
def calculate_month_date(date_value) case date_value when :next_month calculate_next_month_date when :last_month calculate_last_month_date end end
def calculate_next_month_date
-
(Date)
- the first day of the next month
def calculate_next_month_date # Return the first day of the next month next_month = Date.today >> 1 Date.new(next_month.year, next_month.month, 1) end