Project

General

Profile

Patch #41188 ยป refactor-first_wday.patch

Go MAEDA, 2024-08-24 09:01

View differences:

.rubocop_todo.yml
Lint/AssignmentInCondition:
Enabled: false
Lint/BinaryOperatorWithIdenticalOperands:
Exclude:
- 'lib/redmine/helpers/calendar.rb'
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
......
- 'app/models/query.rb'
- 'app/models/role.rb'
- 'lib/redmine/field_format.rb'
- 'lib/redmine/helpers/calendar.rb'
- 'lib/redmine/search.rb'
# Configuration parameters: EnforcedStyle, AllowedPatterns.
lib/redmine/helpers/calendar.rb
# 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
    (1-1/1)