class Faker::Date

def in_date_period(month: nil, year: ::Date.today.year)

Returns:
  • (Date) -

Parameters:
  • year (Integer) -- represents the year of the date
  • month (Integer) -- represents the month of the date
def in_date_period(month: nil, year: ::Date.today.year)
  from = ::Date.new(year, month || 1, 1)
  to = ::Date.new(year, month || 12, ::Date.civil(year, month || 12, -1).day)
  between(from: from, to: to).to_date
end