aboutsummaryrefslogtreecommitdiffstats
path: root/lib/carlosgoce/calendar.rb
blob: ea5bd6a0a7c19115affa1f33533b04d68d3bf4f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'rubygems'
require 'active_support/core_ext/time'
require 'active_support/core_ext/date'

module CarlosGoce
  class Calendar
    attr_reader :year

    def initialize(year=Date.today.year)
      @year = year
    end

    def to_h
      h = {}
      (1..12).each do |month|
        month_name = I18n.t('date.month_names')[month].downcase
        month_days =(1...Time.days_in_month(month, @year)).to_a.each_slice(7).to_a
        h[month_name] = month_days
      end

      h
    end
  end
end