Mercurial > hg > soundsoftware-site
annotate app/helpers/.svn/text-base/calendars_helper.rb.svn-base @ 846:2a298083742b luisf
Merge from branch "bug_365"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 01 Feb 2012 13:20:45 +0000 |
parents | cbce1fd3b1b7 |
children |
rev | line source |
---|---|
chris@22 | 1 module CalendarsHelper |
chris@22 | 2 def link_to_previous_month(year, month, options={}) |
chris@22 | 3 target_year, target_month = if month == 1 |
chris@22 | 4 [year - 1, 12] |
chris@22 | 5 else |
chris@22 | 6 [year, month - 1] |
chris@22 | 7 end |
chris@22 | 8 |
chris@22 | 9 name = if target_month == 12 |
chris@22 | 10 "#{month_name(target_month)} #{target_year}" |
chris@22 | 11 else |
chris@22 | 12 "#{month_name(target_month)}" |
chris@22 | 13 end |
chris@22 | 14 |
chris@22 | 15 link_to_month(('« ' + name), target_year, target_month, options) |
chris@22 | 16 end |
chris@22 | 17 |
chris@22 | 18 def link_to_next_month(year, month, options={}) |
chris@22 | 19 target_year, target_month = if month == 12 |
chris@22 | 20 [year + 1, 1] |
chris@22 | 21 else |
chris@22 | 22 [year, month + 1] |
chris@22 | 23 end |
chris@22 | 24 |
chris@22 | 25 name = if target_month == 1 |
chris@22 | 26 "#{month_name(target_month)} #{target_year}" |
chris@22 | 27 else |
chris@22 | 28 "#{month_name(target_month)}" |
chris@22 | 29 end |
chris@22 | 30 |
chris@22 | 31 link_to_month((name + ' »'), target_year, target_month, options) |
chris@22 | 32 end |
chris@22 | 33 |
chris@22 | 34 def link_to_month(link_name, year, month, options={}) |
Chris@441 | 35 link_to_content_update(link_name, params.merge(:year => year, :month => month)) |
chris@22 | 36 end |
chris@22 | 37 end |