You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calendars_helper.rb 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. module CalendarsHelper
  2. def link_to_previous_month(year, month, options={})
  3. target_year, target_month = if month == 1
  4. [year - 1, 12]
  5. else
  6. [year, month - 1]
  7. end
  8. name = if target_month == 12
  9. "#{month_name(target_month)} #{target_year}"
  10. else
  11. "#{month_name(target_month)}"
  12. end
  13. # \xc2\xab(utf-8) = «
  14. link_to_month(("\xc2\xab " + name), target_year, target_month, options)
  15. end
  16. def link_to_next_month(year, month, options={})
  17. target_year, target_month = if month == 12
  18. [year + 1, 1]
  19. else
  20. [year, month + 1]
  21. end
  22. name = if target_month == 1
  23. "#{month_name(target_month)} #{target_year}"
  24. else
  25. "#{month_name(target_month)}"
  26. end
  27. # \xc2\xbb(utf-8) = »
  28. link_to_month((name + " \xc2\xbb"), target_year, target_month, options)
  29. end
  30. def link_to_month(link_name, year, month, options={})
  31. link_to_content_update(h(link_name), params.merge(:year => year, :month => month))
  32. end
  33. end