diff options
author | Go MAEDA <maeda@farend.jp> | 2024-09-07 06:34:35 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-09-07 06:34:35 +0000 |
commit | 4675febf310a868aa6dd56ec129b1059e83f7099 (patch) | |
tree | dc6ba1a2397ad7958503c44486121591b88f38b6 /lib/redmine | |
parent | 9e28bebbfc47e50892fb1ed93f353e4b8bc9e0f7 (diff) | |
download | redmine-4675febf310a868aa6dd56ec129b1059e83f7099.tar.gz redmine-4675febf310a868aa6dd56ec129b1059e83f7099.zip |
Refactor Calendar#first_wday method for improved readability and efficiency (#41188).
git-svn-id: https://svn.redmine.org/redmine/trunk@23032 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/helpers/calendar.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/redmine/helpers/calendar.rb b/lib/redmine/helpers/calendar.rb index 69ed62b05..9f3962236 100644 --- a/lib/redmine/helpers/calendar.rb +++ b/lib/redmine/helpers/calendar.rb @@ -83,20 +83,19 @@ module Redmine # Return the first day of week # 1 = Monday ... 7 = Sunday def first_wday - 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 - @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1 + @first_wday ||= begin + start_of_week = Setting.start_of_week.to_i + case start_of_week + when 1, 6, 7 + ((start_of_week - 1) % 7) + 1 + else + ((l(:general_first_day_of_week).to_i - 1) % 7) + 1 + end end end def last_wday - @last_dow ||= (first_wday + 5)%7 + 1 + @last_wday ||= ((first_wday + 5) % 7) + 1 end end end |