From 7055dcd7678d926b80d5b0e66b0e16d827920339 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 27 May 2020 02:25:06 +0000 Subject: [PATCH] gantt: simplify week day logic in to_pdf() at lib/redmine/helpers/gantt.rb git-svn-id: http://svn.redmine.org/redmine/trunk@19797 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/helpers/gantt.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 6bd9fc23c..4ea779d16 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -563,35 +563,29 @@ module Redmine left = subject_width height = header_height day_num = self.date_from - wday = self.date_from.cwday pdf.SetFontStyle('B', 7) - (self.date_to - self.date_from + 1).to_i.times do + (self.date_from..self.date_to).each do |g_date| width = zoom pdf.SetY(y_start + header_height * 2) pdf.SetX(left) - pdf.SetTextColor(non_working_week_days.include?(wday) ? 150 : 0) + pdf.SetTextColor(non_working_week_days.include?(g_date.cwday) ? 150 : 0) pdf.RDMCell(width, height, day_num.day.to_s, "LTR", 0, "C") left = left + width day_num = day_num + 1 - wday = wday + 1 - wday = 1 if wday > 7 end end # Days headers if show_days left = subject_width height = header_height - wday = self.date_from.cwday pdf.SetFontStyle('B', 7) - (self.date_to - self.date_from + 1).to_i.times do + (self.date_from..self.date_to).each do |g_date| width = zoom pdf.SetY(y_start + header_height * (show_day_num ? 3 : 2)) pdf.SetX(left) - pdf.SetTextColor(non_working_week_days.include?(wday) ? 150 : 0) - pdf.RDMCell(width, height, day_name(wday).first, "LTR", 0, "C") + pdf.SetTextColor(non_working_week_days.include?(g_date.cwday) ? 150 : 0) + pdf.RDMCell(width, height, day_name(g_date.cwday).first, "LTR", 0, "C") left = left + width - wday = wday + 1 - wday = 1 if wday > 7 end end pdf.SetY(y_start) -- 2.39.5