diff --git a/modules/costs/app/components/my/time_tracking/list_component.rb b/modules/costs/app/components/my/time_tracking/list_component.rb index c8ac1260813..4e63b6f4de6 100644 --- a/modules/costs/app/components/my/time_tracking/list_component.rb +++ b/modules/costs/app/components/my/time_tracking/list_component.rb @@ -52,7 +52,7 @@ module My def range case mode when :day then [date] - when :week then date.all_week + when :week then date.all_week(week_start_day) when :workweek then workweek_days when :month then month_days end @@ -60,7 +60,7 @@ module My def grouped_time_entries @grouped_time_entries ||= time_entries - .group_by { |entry| mode == :month ? entry.spent_on.beginning_of_week : entry.spent_on } + .group_by { |entry| mode == :month ? entry.spent_on.beginning_of_week(week_start_day) : entry.spent_on } .tap do |hash| hash.default_proc = ->(h, k) { h[k] = [] } end @@ -75,8 +75,8 @@ module My end def workweek_days - workdays_normalized = Setting.working_days.map { |day| day % 7 }.sort - date.all_week.select { |d| workdays_normalized.include?(d.wday) } + workdays_normalized = Setting.working_days.map { |day| day % 7 }.sort + date.all_week(week_start_day).select { |d| workdays_normalized.include?(d.wday) } end def month_days @@ -91,15 +91,23 @@ module My end end + def week_start_day + case Setting.start_of_week + when 6 then :saturday + when 7 then :sunday + else :monday + end + end + def collapsed?(date) date.past? end def date_caption(date) if mode == :month - if Date.current.beginning_of_week == date + if Date.current.beginning_of_week(week_start_day) == date t(:label_this_week) - elsif 1.week.ago.beginning_of_week == date + elsif 1.week.ago.beginning_of_week(week_start_day) == date t(:label_last_week) end elsif date.today? diff --git a/modules/costs/app/controllers/my/time_tracking_controller.rb b/modules/costs/app/controllers/my/time_tracking_controller.rb index 50c90c9b023..80845d5413e 100644 --- a/modules/costs/app/controllers/my/time_tracking_controller.rb +++ b/modules/costs/app/controllers/my/time_tracking_controller.rb @@ -75,8 +75,8 @@ module My end def workweek - workdays_normalized = Setting.working_days.map { |day| day % 7 }.sort - date.all_week.select { |d| workdays_normalized.include?(d.wday) } + workdays_normalized = Setting.working_days.map { |day| day % 7 }.sort + date.all_week(week_start_day).select { |d| workdays_normalized.include?(d.wday) } end def parsed_date @@ -116,7 +116,7 @@ module My def current_date case mode when :day then Time.zone.today - when :week, :workweek then Time.zone.today.beginning_of_week + when :week, :workweek then Time.zone.today.beginning_of_week(week_start_day) when :month then Time.zone.today.beginning_of_month end end @@ -145,6 +145,14 @@ module My end end + def week_start_day + case Setting.start_of_week + when 6 then :saturday + when 7 then :sunday + else :monday + end + end + def mobile? browser.device.mobile? end