module WeekOfMonth::Day

Public Instance Methods

all_non_week_days_of_month() click to toggle source

returns array of all non working days of the month Date.new(2014,12,1).all_non_week_days_of_month

> [#<Date: 2014-12-28 ((2457020j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-27 ((2457019j,0s,0n),+0s,2299161j)>,

#<Date: 2014-12-21 ((2457013j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-20 ((2457012j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-14 ((2457006j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-13 ((2457005j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-07 ((2456999j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-06 ((2456998j,0s,0n),+0s,2299161j)>]

# File lib/modules/day.rb, line 102
def all_non_week_days_of_month
  ending_of_month.downto(beginning_of_month).select(&:week_end?)
end
all_working_days_of_month() click to toggle source

returns array of all working days of the month Date.new(2014,12,1).all_working_days_of_month

> [#<Date: 2014-12-31 ((2457023j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-30 ((2457022j,0s,0n),+0s,2299161j)>,

#<Date: 2014-12-29 ((2457021j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-26 ((2457018j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-25 ((2457017j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-24 ((2457016j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-23 ((2457015j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-22 ((2457014j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-19 ((2457011j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-18 ((2457010j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-17 ((2457009j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-16 ((2457008j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-15 ((2457007j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-12 ((2457004j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-11 ((2457003j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-10 ((2457002j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-09 ((2457001j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-08 ((2457000j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-05 ((2456997j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-04 ((2456996j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-03 ((2456995j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-02 ((2456994j,0s,0n),+0s,2299161j)>, #<Date: 2014-12-01 ((2456993j,0s,0n),+0s,2299161j)>]

# File lib/modules/day.rb, line 92
def all_working_days_of_month
  ending_of_month.downto(beginning_of_month).select(&:working_day?)
end
days_array() click to toggle source

gives array of days in month Date.new(2012,1,1).days_array

=> [ 1, 2, 3, 4, 5, 6, 7, 8, 9,
     10, 11, 12, 13, 14, 15, 16,
     17, 18, 19, 20, 21, 22, 23,
     24, 25, 26, 27, 28, 29, 30,
     31]

@return [Array]

# File lib/modules/day.rb, line 22
def days_array
  day = beginning_of_month.to_date.wday
  if WeekOfMonth.configuration.monday_active
    day = day.zero? ? 6 : day - 1
  end
  array = []
  array[day] = 1
  (2..ending_of_month.mday).each { |i| array << i }
  array
end
first_working_day_of_the_month() click to toggle source

returns first working/business day of the month Date.new(2014,12,1).first_working_day_of_the_month

> #<Date: 2014-12-01 ((2456993j,0s,0n),+0s,2299161j)>

# File lib/modules/day.rb, line 109
def first_working_day_of_the_month
  beginning_of_month.upto(ending_of_month).find(&:working_day?)
end
last_business_day_of_month() click to toggle source

gives last working/business day of the month Date.new(2014,12,1).last_business_day_of_month

> #<Date: 2014-12-31 ((2457023j,0s,0n),+0s,2299161j)>

# File lib/modules/day.rb, line 74
def last_business_day_of_month
  all_working_days_of_month.first
end
name_of_week_day() click to toggle source

Date.new(2012,11,1).name_of_week_day

=> 'Thursday'

@return [String]

# File lib/modules/day.rb, line 36
def name_of_week_day
  self.class.new(year, month, day).strftime('%A')
end