Skip to content

Commit c5c3db7

Browse files
committed
Fix week mismatch in profile views
Some parts of the page started weeks with Sunday, others with Monday, causing inconsistencies in the view. Now everything uses ISO weeks starting with Monday.
1 parent 03191bc commit c5c3db7

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

app/controllers/concerns/profile_activity.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,8 @@ def build_contribution_weeks(year, filters: nil)
171171
return [[], []] if ids.blank?
172172

173173
year = year.to_i
174-
start_date = Date.new(year, 1, 1)
175-
end_date = Date.new(year, 12, 31)
176-
start_date -= start_date.wday
177-
end_date += (6 - end_date.wday)
174+
start_date = Date.commercial(year, 1, 1)
175+
end_date = Date.commercial(year, Date.new(year, 12, 28).cweek, 7)
178176

179177
counts = build_filtered_contribution_counts(start_date, end_date, filters)
180178

app/views/shared/profile/_contributions.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ div data-controller="contrib-calendar" data-contrib-calendar-filter-selector-val
2222
- else
2323
span.contrib-week-empty = week[:week]
2424
tbody
25-
- weekday_labels = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
25+
- weekday_labels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
2626
- 7.times do |row|
2727
tr
2828
th.contrib-label = weekday_labels[row]

0 commit comments

Comments
 (0)