From 78af4f429fc834197c6928fc49797fe710cf27fb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 27 Mar 2011 15:43:26 +0000 Subject: [PATCH] Adds support for saturday as the first week day (#7097). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5228 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 2 ++ app/views/settings/_display.rhtml | 2 +- lib/redmine/helpers/calendar.rb | 2 ++ .../unit/lib/redmine/helpers/calendar_test.rb | 24 +++++++++++++++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 35c8a4014..f7400bc9c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -854,6 +854,8 @@ module ApplicationHelper 'Calendar._FD = 1;' # Monday when 7 'Calendar._FD = 0;' # Sunday + when 6 + 'Calendar._FD = 6;' # Saturday else '' # use language end diff --git a/app/views/settings/_display.rhtml b/app/views/settings/_display.rhtml index 97cee5255..25f65fc56 100644 --- a/app/views/settings/_display.rhtml +++ b/app/views/settings/_display.rhtml @@ -5,7 +5,7 @@

<%= setting_select :default_language, lang_options_for_select(false) %>

-

<%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(7),'7']], :blank => :label_language_based %>

+

<%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(6),'6'], [day_name(7),'7']], :blank => :label_language_based %>

<%= setting_select :date_format, Setting::DATE_FORMATS.collect {|f| [Date.today.strftime(f), f]}, :blank => :label_language_based %>

diff --git a/lib/redmine/helpers/calendar.rb b/lib/redmine/helpers/calendar.rb index ec474025b..9b3c0e816 100644 --- a/lib/redmine/helpers/calendar.rb +++ b/lib/redmine/helpers/calendar.rb @@ -68,6 +68,8 @@ module Redmine case Setting.start_of_week.to_i when 1 @first_dow ||= (1 - 1)%7 + 1 + when 6 + @first_dow ||= (6 - 1)%7 + 1 when 7 @first_dow ||= (7 - 1)%7 + 1 else diff --git a/test/unit/lib/redmine/helpers/calendar_test.rb b/test/unit/lib/redmine/helpers/calendar_test.rb index 837523445..f0ac67881 100644 --- a/test/unit/lib/redmine/helpers/calendar_test.rb +++ b/test/unit/lib/redmine/helpers/calendar_test.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -40,4 +40,24 @@ class CalendarTest < ActiveSupport::TestCase c = Redmine::Helpers::Calendar.new(Date.today, :en, :week) assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday] end + + def test_monthly_start_day + [1, 6, 7].each do |day| + with_settings :start_of_week => day do + c = Redmine::Helpers::Calendar.new(Date.today, :en, :month) + assert_equal day , c.startdt.cwday + assert_equal (day + 5) % 7, c.enddt.cwday + end + end + end + + def test_weekly_start_day + [1, 6, 7].each do |day| + with_settings :start_of_week => day do + c = Redmine::Helpers::Calendar.new(Date.today, :en, :week) + assert_equal day, c.startdt.cwday + assert_equal (day + 5) % 7 + 1, c.enddt.cwday + end + end + end end -- 2.39.5