4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/simple_calendar/view_helpers.rb', line 4
def calendar(events, options={}, &block)
raise 'SimpleCalendar requires a block to be passed in' unless block_given?
opts = {
:year => (params[:year] || Time.zone.now.year).to_i,
:month => (params[:month] || Time.zone.now.month).to_i,
:prev_text => raw("«"),
:next_text => raw("»"),
:start_day => :sunday
}
options.reverse_merge! opts
events ||= []
selected_month = Date.civil(options[:year], options[:month])
current_date = Date.today
range = build_range selected_month, options
month_array = build_month range
draw_calendar(selected_month, month_array, current_date, events, options, block)
end
|