Module: MonthDate
- Defined in:
- lib/month_date.rb,
lib/month_date/version.rb
Constant Summary collapse
- VERSION =
"0.0.2.1"
Class Method Summary collapse
- .date_in_month(year, month) ⇒ Object
- .days_in_month(year, month) ⇒ Object
- .week_date_in_month(year, month, week) ⇒ Object
Class Method Details
.date_in_month(year, month) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/month_date.rb', line 22 def MonthDate.date_in_month(year, month) days = self.days_in_month(year, month) ary = [] days.upto(1) do |day| date = Date.new(year, month, day) ary << date.strftime("%Y%m%d") end return ary end |
.days_in_month(year, month) ⇒ Object
18 19 20 |
# File 'lib/month_date.rb', line 18 def MonthDate.days_in_month(year, month) Date.new(year, month, -1).day end |
.week_date_in_month(year, month, week) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/month_date.rb', line 6 def MonthDate.week_date_in_month(year, month, week) days = self.days_in_month(year, month) result = [] 1.upto(days) do |day| date = Date.new(year, month, day) if date.wday == week result << date.strftime("%Y%m%d") end end return result end |