module EventsHelper #DAYNAMES = [:mon, :tue, :wed, :thu, :fri, :sat, :sun] def calendar(yeard,monthd,addMonths) now = DateTime.now first = Date.new(now.year,now.month,1) last = Date.new(now.year,now.month,-1) curr_week = first.cweek html = "
" 1.upto(6) do |i| html << " | #{t(:abbr_day_names,:scope=>:date)[i]} | " end html << "#{t(:abbr_day_names,:scope=>:date)[0]} | " html << "||
#{first.cweek} | " (first.wday-1).downto(1) do |i| prev = first - i html << "#{prev.day} | " end (first.day).upto(last.day) do |i| curr = Date.new(now.year,now.month,i) if curr.wday == 1 html << "|||
#{curr_week} | " end if now.day == i html << "#{i} | " else if curr.wday == 0 || curr.wday == 6 html << "#{i} | " else html << "#{i} | " end end end 1.upto(7-last.wday) do |i| post = last + i html << "#{post.day} | " end html << "