Patch #41188 ยป refactor-first_wday.patch
| .rubocop_todo.yml | ||
|---|---|---|
| 180 | 180 |
Lint/AssignmentInCondition: |
| 181 | 181 |
Enabled: false |
| 182 | 182 | |
| 183 |
Lint/BinaryOperatorWithIdenticalOperands: |
|
| 184 |
Exclude: |
|
| 185 |
- 'lib/redmine/helpers/calendar.rb' |
|
| 186 | ||
| 187 | 183 |
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. |
| 188 | 184 |
Lint/DuplicateBranch: |
| 189 | 185 |
Exclude: |
| ... | ... | |
| 297 | 293 |
- 'app/models/query.rb' |
| 298 | 294 |
- 'app/models/role.rb' |
| 299 | 295 |
- 'lib/redmine/field_format.rb' |
| 300 |
- 'lib/redmine/helpers/calendar.rb' |
|
| 301 | 296 |
- 'lib/redmine/search.rb' |
| 302 | 297 | |
| 303 | 298 |
# Configuration parameters: EnforcedStyle, AllowedPatterns. |
| lib/redmine/helpers/calendar.rb | ||
|---|---|---|
| 83 | 83 |
# Return the first day of week |
| 84 | 84 |
# 1 = Monday ... 7 = Sunday |
| 85 | 85 |
def first_wday |
| 86 |
case Setting.start_of_week.to_i |
|
| 87 |
when 1 |
|
| 88 |
@first_dow ||= (1 - 1)%7 + 1 |
|
| 89 |
when 6 |
|
| 90 |
@first_dow ||= (6 - 1)%7 + 1 |
|
| 91 |
when 7 |
|
| 92 |
@first_dow ||= (7 - 1)%7 + 1 |
|
| 93 |
else |
|
| 94 |
@first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1 |
|
| 86 |
@first_wday ||= begin |
|
| 87 |
start_of_week = Setting.start_of_week.to_i |
|
| 88 |
case start_of_week |
|
| 89 |
when 1, 6, 7 |
|
| 90 |
((start_of_week - 1) % 7) + 1 |
|
| 91 |
else |
|
| 92 |
((l(:general_first_day_of_week).to_i - 1) % 7) + 1 |
|
| 93 |
end |
|
| 95 | 94 |
end |
| 96 | 95 |
end |
| 97 | 96 | |
| 98 | 97 |
def last_wday |
| 99 |
@last_dow ||= (first_wday + 5)%7 + 1
|
|
| 98 |
@last_wday ||= ((first_wday + 5) % 7) + 1
|
|
| 100 | 99 |
end |
| 101 | 100 |
end |
| 102 | 101 |
end |