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 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # encoding: utf-8
  2. #
  3. # Redmine - project management software
  4. # Copyright (C) 2006-2012 Jean-Philippe Lang
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. module CalendarsHelper
  20. def link_to_previous_month(year, month, options={})
  21. target_year, target_month = if month == 1
  22. [year - 1, 12]
  23. else
  24. [year, month - 1]
  25. end
  26. name = if target_month == 12
  27. "#{month_name(target_month)} #{target_year}"
  28. else
  29. "#{month_name(target_month)}"
  30. end
  31. # \xc2\xab(utf-8) = «
  32. link_to_month(("\xc2\xab " + name), target_year, target_month, options)
  33. end
  34. def link_to_next_month(year, month, options={})
  35. target_year, target_month = if month == 12
  36. [year + 1, 1]
  37. else
  38. [year, month + 1]
  39. end
  40. name = if target_month == 1
  41. "#{month_name(target_month)} #{target_year}"
  42. else
  43. "#{month_name(target_month)}"
  44. end
  45. # \xc2\xbb(utf-8) = »
  46. link_to_month((name + " \xc2\xbb"), target_year, target_month, options)
  47. end
  48. def link_to_month(link_name, year, month, options={})
  49. link_to_content_update(h(link_name), params.merge(:year => year, :month => month))
  50. end
  51. end