]> source.dussan.org Git - redmine.git/commitdiff
gantt: simplify week day logic in to_pdf() at lib/redmine/helpers/gantt.rb
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 27 May 2020 02:25:06 +0000 (02:25 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 27 May 2020 02:25:06 +0000 (02:25 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@19797 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/helpers/gantt.rb

index 6bd9fc23c05c4743ee0225f2465f60f453b70bbd..4ea779d1638cf8d5f7652eb0854207a56d067978 100644 (file)
@@ -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)