module WeekOfMonth::Month

Public Instance Methods

beginning_of_month() click to toggle source

returns date of first day of month for a given date. Date.new(2012,11,1).beginning_of_month

=> #<Date: 2012-11-01 ((2456233j,0s,0n),+0s,2299161j)>

@return [Date]

# File lib/modules/month.rb, line 42
def beginning_of_month
  self.class.new(year, month, 1)
end
ending_of_month() click to toggle source

returns date of last day of month for a given date. Date.new(2012,11,1).ending_of_month

=> #<Date: 2012-11-30 ((2456262j,0s,0n),+0s,2299161j)>

@return [Date]

# File lib/modules/month.rb, line 34
def ending_of_month
  self.class.new(year, month, last_day_of_month)
end
last_day_of_month() click to toggle source

returns day of last day of month for a given date. Date.new(2012,11,1).last_day_of_month

=> 30

@return [Fixnum]

# File lib/modules/month.rb, line 22
def last_day_of_month
  if leap? && february?
    29
  else
    MONTH_WITH_DAY[MONTH_WITH_SEQUENCE.key(month)]
  end
end
name_of_month() click to toggle source

returns name of month for a given date. Date.new(2012,11,1).name_of_month

=> "November"

@return [String]

# File lib/modules/month.rb, line 50
def name_of_month
  self.class.new(year, month, day).strftime('%B')
end