module Holidays::CoreExtensions::Date

def self.included(base)

def self.included(base)
  base.extend ClassMethods
end

def change(options)

Date.new(2007, 5, 12).change(year: 2005, month: 1) # => Date.new(2005, 1, 12)
Date.new(2007, 5, 12).change(day: 1) # => Date.new(2007, 5, 1)

The +options+ parameter is a hash with a combination of these keys: :year, :month, :day.
Returns a new Date where one or more of the elements have been changed according to the +options+ parameter.
def change(options)
  ::Date.new(
    options.fetch(:year, year),
    options.fetch(:month, month),
    options.fetch(:day, day)
  )
end

def end_of_month

def end_of_month
  last_day = ::Time.days_in_month( self.month, self.year )
  change(:day => last_day)
end

def holiday?(*options)

=> true
Date.civil('2008-01-01').holiday?(:ca)

Returns true or false.

Check if the current date is a holiday.
def holiday?(*options)
  holidays = self.holidays(*options)
  holidays && !holidays.empty?
end

def holidays(*options)

Also available via Holidays#on.

=> [{:name => 'New Year\'s Day',...}]
Date.civil('2008-01-01').holidays(:ca_)

and the output format.
Returns an array of hashes or nil. See Holidays#between for options

Get holidays on the current date.
def holidays(*options)
  Holidays.on(self, *options)
end