summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-03-27 15:43:26 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-03-27 15:43:26 +0000
commit78af4f429fc834197c6928fc49797fe710cf27fb (patch)
tree174a7b5101f567fc3dcc9227e2c8d4968af91ea6
parent3ef5daaf35185cf20a79ca38334abe0074f58549 (diff)
downloadredmine-78af4f429fc834197c6928fc49797fe710cf27fb.tar.gz
redmine-78af4f429fc834197c6928fc49797fe710cf27fb.zip
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
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/views/settings/_display.rhtml2
-rw-r--r--lib/redmine/helpers/calendar.rb2
-rw-r--r--test/unit/lib/redmine/helpers/calendar_test.rb24
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 @@
<p><%= setting_select :default_language, lang_options_for_select(false) %></p>
-<p><%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(7),'7']], :blank => :label_language_based %></p>
+<p><%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(6),'6'], [day_name(7),'7']], :blank => :label_language_based %></p>
<p><%= setting_select :date_format, Setting::DATE_FORMATS.collect {|f| [Date.today.strftime(f), f]}, :blank => :label_language_based %></p>
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