diff options
author | Carlos Goce <carlosgoce@gmail.com> | 2015-01-23 00:07:05 +0100 |
---|---|---|
committer | Carlos Goce <carlosgoce@gmail.com> | 2015-01-23 00:07:05 +0100 |
commit | 2d10c61b2f1d43fa98b46bdd17cfce86da95b7e5 (patch) | |
tree | ac09ce9874f52e363799df319255f29a94ed36ba /lib | |
parent | e8341ef9884861fc24040d4f219a271ae1022722 (diff) | |
download | pdf-calendars-2d10c61b2f1d43fa98b46bdd17cfce86da95b7e5.tar.gz pdf-calendars-2d10c61b2f1d43fa98b46bdd17cfce86da95b7e5.tar.bz2 pdf-calendars-2d10c61b2f1d43fa98b46bdd17cfce86da95b7e5.zip |
Calendar can localize months
Diffstat (limited to 'lib')
-rw-r--r-- | lib/carlosgoce/calendar.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/carlosgoce/calendar.rb b/lib/carlosgoce/calendar.rb index cb77325..ea5bd6a 100644 --- a/lib/carlosgoce/calendar.rb +++ b/lib/carlosgoce/calendar.rb @@ -1,7 +1,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 - {enero: []} + 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
\ No newline at end of file |